002_qml矩阵的使用方式

学习内容:

  1. 学习Rectangle(矩形)的用法
    基础属性:x,y,width,height,color
    显示优先级:
    z: 默认为0,数字越大优先级越高
  2. 鼠标点击事件:
cpp 复制代码
	MouseArea{
		//设置鼠标填充该Rectangle
		anchors.fill : parent 
		onClicked: {
			console.log("onClicked")
		}
	}
  1. 键盘事件
cpp 复制代码
	//按下回车, 当前事件获取到焦点才可以操作
	Keys.onReturnPressed: {
		console.log("onReturnPressed")
	}
  1. 控件锚点(通过锚点的方式来设置控件的相对位置)
cpp 复制代码
例如:
	// 设置一个控件
	Rectangle {
		id: rect1
		width: 200
		height: 100
		color: "blue"
	}
	// 控件2的位置
	方式1:直接在1的基础上进行操作
		x: rect1.width + 20
	方式2:
	在1的基础上设置间距
		anchors.left: rect1.right
		anchors.leftMargin: 20
		anchors.top: rect1.bottom
        anchors.topMargin: 20
		//居中于整个界面
        anchors.centerIn: parent
  1. 旋转和缩放
cpp 复制代码
	// 旋转 顺时针 旋转30度
	rotation: 30
	//缩放倍数
	scale: 2
  1. 圆弧和渐变色
cpp 复制代码
	//圆角弧度
	radius: 50
	//渐变颜色
	gradient: Gradient{
		GradientStop { position: 0.0 ; color: "lightsteelblue"}
		GradientStop { position: 0.5 ; color: "green"}
		GradientStop { position: 1.0 ; color: "blue"}
	}
相关推荐
ShineWinsu1 天前
对于Qt:信号量(QSemaphore)的解析
c++·qt·面试·笔试·客户端·线程安全·信号量
ShineWinsu2 天前
对于Qt:条件变量(QWaitCondition)的解析
c++·qt·面试·线程·条件变量·客户端·锁
郝学胜-神的一滴3 天前
Effective STL 条款12:对容器线程安全性的现实期望
c语言·开发语言·c++·qt·网络协议·rpc·numpy
敲上瘾3 天前
Qt 常用控件:按钮、显示输入、容器与布局等
开发语言·c++·qt·qt6.3
ShineWinsu4 天前
对于Qt:事件分发器以及事件过滤器的解析
c++·qt·面试·gui·客户端·事件过滤器·事件分发器
ShineWinsu4 天前
对于Qt:事件的解析
c++·qt·面试·笔试·gui·客户端·事件
西西弗Sisyphus5 天前
Qt QML 程序是怎么跑起来的(1)qml-only
开发语言·c++·qt
小灰灰搞电子5 天前
QAccel 类讲解与代码示例:Qt 3 中的键盘加速键管理
qt·计算机外设
ShineWinsu6 天前
对于Qt:重写事件步骤的解析
开发语言·c++·qt·客户端·事件·鼠标事件·步骤
敲上瘾6 天前
Qt控件通用属性:geometry、qrc资源到QSS样式表等
开发语言·c++·qt·ui