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"}
	}
相关推荐
CodeByV4 分钟前
【Qt】信号与槽
开发语言·qt
枫叶丹431 分钟前
【Qt开发】Qt系统(十一)-> Qt 音频
c语言·开发语言·c++·qt·音视频
qq_3975623115 小时前
QT工程 , 生成别的电脑运行的exe程序
嵌入式硬件·qt
轩情吖15 小时前
Qt的窗口
开发语言·c++·qt·窗口·工具栏·桌面级开发
凯子坚持 c15 小时前
Qt常用控件指南(8)
开发语言·数据库·qt
深蓝海拓16 小时前
PySide6从0开始学习的笔记(二十六) 重写Qt窗口对象的事件(QEvent)处理方法
笔记·python·qt·学习·pyqt
深蓝海拓18 小时前
PySide6从0开始学习的笔记(二十五) Qt窗口对象的生命周期和及时销毁
笔记·python·qt·学习·pyqt
从此不归路1 天前
Qt5 进阶【13】桌面 Qt 项目架构设计:从 MVC/MVVM 到模块划分
开发语言·c++·qt·架构·mvc
无小道1 天前
QT——简介
qt
xmRao1 天前
Qt+FFmpeg 实现音频重采样
qt·ffmpeg·音视频