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"}
	}
相关推荐
lqjun08272 小时前
Qt程序单独运行报错问题
开发语言·qt
酷飞飞9 小时前
Qt Designer与事件处理
开发语言·qt·命令模式
mkhase11 小时前
9.12-QT-基本登陆界面实现
java·jvm·qt
咕噜咕噜啦啦11 小时前
Qt之快捷键、事件处理、自定义按键——完成记事本项目
开发语言·qt
Quz12 小时前
QML Charts组件之折线图的鼠标交互
qt
眠りたいです14 小时前
基于脚手架微服务的视频点播系统-数据管理与网络通信部分的预备工作
c++·qt·ui·微服务·云原生·架构·媒体
bikong716 小时前
Qt/C++,windows多进程demo
c++·windows·qt
油炸自行车18 小时前
【Qt】Window环境下搭建Qt6、MSVC2022开发环境(无需提前安装Visual Studio)
qt·visual studio·qt6·msvc2022·qt creator 17.0
枫叶丹418 小时前
【Qt开发】显示类控件(三)-> QProgressBar
开发语言·qt
姓刘的哦1 天前
Qt中的QWebEngineView
数据库·c++·qt