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"}
	}
相关推荐
十五年专注C++开发9 分钟前
Qt .pro配置gcc相关命令(三):-W1、-L、-rpath和-rpath-link
linux·运维·c++·qt·cmake·跨平台编译
Cai junhao33 分钟前
【Qt】Qt控件
开发语言·c++·笔记·qt
uyeonashi41 分钟前
【QT系统相关】QT网络
开发语言·网络·c++·qt
Simple_core1 小时前
Qt3d中的材质--PBR材质
qt·3d·材质
我真不会起名字啊4 小时前
Qt如何生成和使用DLL动态链接库
开发语言·qt
lansye10 小时前
侃侃AI编程
开发语言·qt·ai编程
uyeonashi12 小时前
【QT】窗口详解
开发语言·c++·qt·学习
追风赶月、17 小时前
【QT】控件一(QWidget、Button、Label)
开发语言·qt
十秒耿直拆包选手20 小时前
Qt:Qt桌面程序正常退出注意事项
c++·qt
姆路20 小时前
Qt背景平铺
开发语言·qt