qml 键盘事件
摘要:1、常用键盘事件 上下左右 event.key Qt.Key_Up event.key Qt.Key_Down event.key Qt.Key_Left event.key Qt.Key_Right 回车 event.key Qt.Key_Enter || event.key Qt.Key_Ret
阅读全文
posted @
2023-05-05 16:07
缘随风烬
阅读(386)
推荐(0)
QML -->画布
摘要:import QtQuick 2.0 import QtQuick.Controls 1.4 Canvas { id: root // canvas size width: 200; height: 200 // handler to override for drawing onPaint: {
阅读全文
posted @
2021-09-23 15:30
缘随风烬
阅读(148)
推荐(0)
QML -- 》控件的添加与删除
摘要:import QtQuick 2.0 Rectangle { width: 480 height: 300 color: "white" ListModel { id: theModel ListElement { number: 0 } ListElement { number: 1 } List
阅读全文
posted @
2021-08-12 15:03
缘随风烬
阅读(509)
推荐(0)
QML --》 GridView(网格视图)
摘要:import QtQuick 2.0 Rectangle{ width: 240; height: 300; color: "white" GridView{ anchors.fill: parent anchors.margins: 20 clip: true // 设置clip属性为true,来
阅读全文
posted @
2021-08-12 14:35
缘随风烬
阅读(907)
推荐(0)
QML -- > ListView(列表视图)
摘要:1、对于用户,ListView是一个滚动区域,支持惯性滚动。(代理项delegates) import QtQuick 2.0 Rectangle{ width: 80 height: 300 color: "white" ListView{ anchors.fill: parent anchors
阅读全文
posted @
2021-08-12 09:47
缘随风烬
阅读(3262)
推荐(0)
QML --> ListModel(链表模型)的简单使用
摘要:一个链表模型(ListModel)是由许多个链表元素(ListElement)组成。 import QtQuick 2.0 Column{ spacing: 2 Repeater{ model:ListModel{ ListElement{name:"单机"; surfaceColor:"gray"
阅读全文
posted @
2021-08-11 16:57
缘随风烬
阅读(1699)
推荐(0)
QML -->状态与过渡(简单的交通灯)
摘要:import QtQuick 2.0 Item{ id:root; state: "go" // 设置初始状态 states: [ State { // 设置每个目标的颜色,并命名 name: "go" PropertyChanges {target: light1; color:"green"}
阅读全文
posted @
2021-08-06 17:16
缘随风烬
阅读(281)
推荐(0)
QML -- 》 动画分组(二)
摘要:Item{ id:root; width: 480; height: 300; property int duration: 3000; // 设置时间3000ms Rectangle{ // 设置天空颜色 id:sky; width: parent.width; height: 200; grad
阅读全文
posted @
2021-08-06 15:34
缘随风烬
阅读(78)
推荐(0)
QML --》动画分组
摘要:1、平行动画 关键字(ParallelAnimation):当开始时,平行元素的所有子动画都会平行运行,它允许你在同一时间使用不同的属性来播放动画。 import QtQuick 2.0 Rectangle{ id:root width: 1000; height: 1000; property i
阅读全文
posted @
2021-08-06 10:26
缘随风烬
阅读(103)
推荐(0)
QML --》 动画元素
摘要:1、PropertyAnimation(属性动画) - 使用属性值改变播放动画。 2、NumberAnimation(数字动画) - 使用数字改变播放的动画。 3、ColorAnimation(颜色动画) - 使用颜色改变播放的动画。 4、RotationAnimation(旋转动画) - 使用旋转
阅读全文
posted @
2021-08-05 16:37
缘随风烬
阅读(288)
推荐(0)
QML -->按键元素
摘要:1、属性key允许你通过按键来执行你的代码,如up, down, left, right。 import QtQuick 2.0 Rectangle{ width: 400; height: 200; GreenRect{ // 封装的绿色方框组件 id:square; x:8;y:8; } foc
阅读全文
posted @
2021-08-05 14:37
缘随风烬
阅读(149)
推荐(0)
QML --》 文本输入TextInput与TextEdit
摘要:1、文本输入 文本输入允许用户输入一行文字。 import QtQuick 2.0 Rectangle{ width: 200; height: 80; color: "linen"; TextInput{ id:input1 x:8;y:8; width: 96; height: 20; focu
阅读全文
posted @
2021-08-05 11:45
缘随风烬
阅读(952)
推荐(0)
QML --> 定位器与Repeater(重复元素)
摘要:1、定位器Row Row的就是行的意思,就是按从左到右方向排列。 2、定位器Column Column(列)将它的子对象通过顶部对齐的方式进行排列。 3、定位器Grid Grid(栅格)通过设置行数和列数将对象排列在一个栅格中,行数或列数可只设置一个,栅格元素会自动的计算子项目总数来获取配置。 4、
阅读全文
posted @
2021-08-04 15:51
缘随风烬
阅读(1469)
推荐(0)
QML --> 简单平移、旋转和缩放
摘要:一、改变物体的几何状态,实现对象的平移、旋转和缩放。 1、平移: 简单的平移是通过改变x,y坐标来实现的。 2、旋转: 旋转是通过改变rotation属性来实现的,这个值是使用角度来作为单位的(0,360) 3、缩放: 缩放是通过关键字scale属性来实现的,小于1表示缩小,大于1表示放大。 4、I
阅读全文
posted @
2021-08-04 15:01
缘随风烬
阅读(2062)
推荐(0)
QML --》矩形框
摘要:1、关键字 Rectangle{} color:颜色 border.color:边框颜色 border.width:边框宽度 radius:圆角 2、添加渐变色: gradient: Gradient{ GradientStop{position: 0.0; color: "black"} Grad
阅读全文
posted @
2021-08-03 16:11
缘随风烬
阅读(730)
推荐(0)
QML -->变量和函数
摘要:1、在qml中定义变量的方法: property int spacePresses: 0 其中property为关键字, int为类型, spacePresses为变量名, 0表示值 2、定义函数的方法 function increment(){ spacePresses = spacePresse
阅读全文
posted @
2021-08-03 15:58
缘随风烬
阅读(2663)
推荐(0)
QML---》初写qml代码
摘要:1、初识QML QML是与HTML类似的一种标记语言。在QtQuick中将由标签组成的元素封装在大括号中 Item{} 。这样的设计重新定义了界面的创建方式,对于开发者而言更加简单易读。可以使用JavaScript开发界面功能,也可以使用本地Qt C++函数接口扩展界面功能。简单来说,声明式的UI被
阅读全文
posted @
2021-08-03 15:22
缘随风烬
阅读(417)
推荐(0)