QML属性汇总

QML学习【一】QML语言基础 QML语言基础 阅读详情
import QtQuick 1.0
/*
3.基本元素的介绍
基本可视化项
Item 基本的项元素 在QML中所有可视化的向都继承他
Rectangle 基本的可视化矩形元素
Gradient 定义一个两种颜色的渐变过程
GradientStop 定义个颜色,被Gradient使用
Image 在场景中使用位图
BorderImage (特殊的项) 定义一张图片并当做边界
AnimatedImage 为播放动画存储一系列的帧
Text 在场景中使用文本
TextInput 显示可编辑为文本
IntValidator int 验证器
DoubleValidator double 验证器
RegExpValidator 验证字符串正则表达式
TextEdit 显示多行可编辑文本
基本的交互项
MouseArea 鼠标句柄交互
FocusScope 键盘焦点句柄
Flickable 提供一种浏览整张图片的一部分的效果,具体看例子
Flipable 提供一个平面,可以进行翻转看他的前面或后面,具体看例子
状态
State 定义一个配置对象和属性的集合
PropertyChanges 使用一个State描述属性的改变
StateGroup 包含一个状态集合和状态变换
ParentChange 重新定义父集,也就是换个父节点
AnchorChanges 在一个状态中改变anchors
动画和变换
Behavior 默认的属性变换动画
SequentialAnimation 对定义的动画串行播放
ParallelAnimation 对定义的动画并行播放
PropertyAnimation 属性变换动画
NumberAnimation 对实数类型属性进行的动画
Vector3dAnimation 对QVector3d进行的属性
ColorAnimation 颜色进行的变换动画
RotationAnimation 对旋转进行的变换动画
ParentAnimation 对父节点进行变换的动画,改变绑定的父节点
AnchorAnimation 对anchor 进行改变的动画
PauseAnimation 延迟处理
SmoothedAnimation 允许属性平滑的过度
SpringAnimation 一种加速的效果
PropertyAction 允许在动画过程中对属性的直接改变
ScriptAction 允许动画过程中调用脚本
Transition 在状态变换中加入动作变化
工作中的数据
Binding 在创建的时候绑定一些数据到一些属性
ListModel 定义链表数据
ListElement 定义ListModel的一个数据项
VisualItemModel 包含可视化项(visual items)到一个view中,相当是一个容器
VisualDataModel 包含一个model和一个delegate,model包含需要的数据,delegate设计显示的项的信息,具体的去看例子
Package 他的目的是把VisualDataModel共享给多个view,具体还要学习
XmlListModel 特殊的一个模式使用XPath表达式,使用xml来设置元素,参考例子
XmlRole XmlListModel的一个特殊的角色
试图
ListView 提供一个链表显示模型试图
GridView 提供一个网格显示模型试图
PathView 提供一个内容沿着路径来显示的模型
Path 定义一个PathView使用的轨迹
PathLine 定义一个线性的轨迹
PathQuad 定义一个二次贝塞尔曲线的轨迹
PathCubic 定义一个三次贝塞尔曲线的轨迹
PathAttribute 允许绑定一个属性上,具体看例子
PathPercent 修改item分配的轨迹 不是很明了其中的意思
WebView 允许添加网页内容到一个canvas上
定位器
Column 整理它的子列(纵)
Row 整理它的子行(横)
Grid 设置它的子到一个网格上
Flow 目的是不让他的子项重叠在一起
实用
Connections 明确连接信号和信号句柄
Component 封装QML items 想一个组件一样
Timer 提供时间触发器
QtObject 基本的元素只包含objectName属性
Qt qml全局Qt object提供使用的枚举和函数
WorkerScript 允许在QML使用线程
Loader 控制载入item或组件
Repeater 使用一个模型创建多个组件
SystemPalette 为Qt palettes提供一个通道
FontLoader 载入字体根据名字或URL
LayoutItem 允许声明UI元素插入到qtGraphicsView 布局中
变换
Scale 分派item 缩放行为
Rotation 分派item 旋转行为
Translate 分派item 移动行为
*/
//1.Item位置是0,0 宽高分别是200
/*Item{
 x:0; y:0
 width:200; height:200
}*/
//2. Rectangle位置是:0,0宽高分别是200, 颜色是红色
/*Rectangle{
 x:0; y:0
 height:200
 width:200
 color:"red"
}*/
//3. Gradient GradientStop 分别在总高度的0 颜色红色 总高度的1/3 黄色 总高度的1是绿色
/*Rectangle{
 width:100; height:200
 gradient: Gradient{
 GradientStop{ position:0.0; color:"red"}
 GradientStop{ position:0.33; color:"yellow"}
 GradientStop{ position:1.0; color:"green"}
 }
}*/
//4. Image 设置一张图片
/*Image{
 source: "img/bottom_dch.png"
}*/
/*
5. BorderImage 他将一张图片分成9部分
当图片进行缩放的时候
A.1 3 7 9 位置的都不会进行缩放
B. 2 8将根据属性horzontalTileMode 进行缩放
C.4 6 将根据属性verticalTileMode 进行缩放
D.5 将根据属性horzontalTileMode 和 verticalTileMode 进行缩放
*/
/*BorderImage {
 width:180; height:180
 // 分割1~9块的4个点是根据border设置的坐标来实现的
 // 本别是距离坐标 上边 右边 下边的距离
 border { left: 30; top: 30; right: 30; bottom: 30 }
 horizontalTileMode: BorderImage.Stretch
 verticalTileMode: BorderImage.Stretch
 source: "img/bottom_dch.png"
}*/
//7. Text 显示文本(具体的其他设置请看文档)
/*Text{
 text:"Text"
}*/
//8. TextInput 下面是设置一个输入文本框,框中的字符串是Text, 并设置鼠标可以选择文本
/*TextInput
{
 text:"Text"
 selectByMouse: true; //鼠标可以选择
}*/
//9.IntValidator int 型验证器,和输入框结合后就是只能输入整型数据
/*TextInput{
 //最高可以输入100, 最低输入10
 IntValidator{ id:intval; bottom:10; top:100}
 width:100; height:20
 text:"aaaaaaaaa";
 validator: intval;
}*/
//10. DoubleValidator 只能输入浮点数
/*TextInput{
 // 最高可以输入100, 最低输入10 decimals最多有多少位小数
 // notation 表示是使用科学计数法还是(默认),还是直接的小数 当获取里面的数据
 DoubleValidator{ id:intval; decimals: 4; bottom:10; top:100; notation: DoubleValidator.StandardNotation}
 width:100; height:20;
 text:""
 validator: intval;
}*/
//11. RegExpValidator 使用正则表达式
/*TextInput{
 //使用一个正则表达式来控制输入的字符串
 // /^[a-zA-Z]{1}[0-1]{0,2}[a-z]{1,3}$/ 表示 开始位置必须是一个大写或小写字母
 // 接下来是0~2个的数字而且是0或1,在接下来是1~3个的小写字母
 RegExpValidator{id:intval; regExp:/^[a-zA-Z]{1}[0-1]{0,2}[a-z]{1,3}$/;}
 width:100; height:20;
 text:""
 validator: intval;
}*/
//12. TextEdit 显示一段hello world的html文本和TextInput相同
/*TextEdit{
 width:240;
 text:"Hello World!"
 font.family: "Helvetica"
 font.pointSize: 20
 color:"blue"
 focus: true
}*/
//13. MouseArea 主要是用来判断鼠标事件的区域
/*Rectangle{
 x:0; y:0
 width:100; height:100
 Rectangle{
 id:mousearea
 x:20; y:20
 width:20; height:20
 color:"red"
 MouseArea{
 anchors.fill: parent
 //但鼠标按下后 mousrect变成红色,当鼠标松开后变成蓝色
 onPressed: { mousearea.color="blue"}
 onReleased: { mousearea.color="red"}
 }
 }
}*/
//14. FocusScope/
//不是很清楚说的什么,好像是说同一个时刻只有一个item有焦点
//15. Flickable 显示一个200x200的框,框中显示图片上200x200的部分
/*Flickable{
 width:200; height:200
 //设置使用图片的宽 高,而现实的是 200x200的现实框
 contentHeight: img.height; contentWidth: img.width;
 Image{ id:img; source: "img/bottom_dch.png"}
}*/
//16. Flipable 包含两个面,一个前面,一个后面,实现一个控件前后的翻转效果,并且在后面可以添加一些控制
/*Flipable{
 id:flipable
 width:240
 height:240
 property int angle: 0
 property bool flipped: false
 front: Image{ source: "img/bottom_dch.png"} //前面
 back: Image{ source: "img/bottom_jk.png"}//后面
 // 旋转动画 前后面交换
 transform: Rotation{
 origin.x: flipable.width/2; origin.y:flipable.height/2
 axis.x: 0; axis.y: 1; axis.z:0
 angle:flipable.angle
 }
 states:State{
 name:"back"
 PropertyChanges{ target:flipable; angle:180}
 when:flipable.flipped
 }
 transitions: Transition{
 NumberAnimation{ properties: "angle"; duration: 1000}
 }
 MouseArea{
 anchors.fill: parent
 onClicked: flipable.flipped = !flipable.flipped
 }
}*/
//17. State // 当鼠标按下后改变 myRect 的颜色
/*Rectangle{
 id:myRect
 width:100; height:100
 color:"black"
 MouseArea{
 anchors.fill: parent
 onClicked: myRect.state =="clicked" ? myRect.state="" : myRect.state="clicked";
 }
 states:[
 State{
 name:"clicked"
 PropertyChanges{ target: myRect; color:"red"}
 }
 ]
}*/
//18. PropertyChanges
// 当鼠标按下后改变状态
// 状态里面的属性改变包含了文本和颜色的改变
/*Text{
 id:mytext
 width:100; height:100
 text:"Hello"
 color:"blue"
 states: [
 State {
 name:"myState"
 // 当这个状态被设置的时候,将改变myText的文本和颜色
 PropertyChanges{ target:mytext; text:"Goodbye"; color:"red"; height:150; width:150 }
 }
 ]
 MouseArea{
 anchors.fill: parent
 onClicked: mytext.state=="myState" ? mytext.state="" : mytext.state="myState"
 }
}*/
//19. StateGroup一个状态组中可以包含很多的状态和变化,而状态也可以和变换绑定.
//20. StateChangeScript
//在状态中可以对脚本中的函数进行调用
/*import "Sc.js" as Code
Rectangle{
 id:rect
 width:50; height:50
 color:"red"
 MouseArea{
 anchors.fill: parent
 onClicked:rect.state="first"
 }
 states: [
 State{
 name:"first";
 StateChangeScript{
 name:"myScript"
 script:rect.color = Code.changeColor();
 }
 }
 ]
}*/
//21. ParentChang把指定的item换一个item父节点
/*Item{
 width:200; height:200
 Rectangle{
 id:redRect
 width:100; height:100
 color:"red"
 }
 //本来blueRect的父节点是Item当鼠标按下后他被设置到redRect上
 Rectangle{
 id:blueRect
 x:redRect.width;
 width:50; height:50
 color:"blue"
 states: State{
 name:"reparented"
 //改变父节点
 ParentChange{ target: blueRect; parent:redRect; x:10; y:10}
 }
 MouseArea{
 anchors.fill: parent
 //onClicked: blueRect.state="reparented";
 onClicked:blueRect.state=="reparented" ? blueRect.state="" : blueRect.state="reparented";
 }
 }
}*/
//22. AnchorChanges
/*Rectangle{
 id:window
 width:120; height:120
 color:"black"
 Rectangle{
 id:myRect; width:50; height:50; color:"red"
 }
 states: [
 State {
 name: "reanchored"
 AnchorChanges{
 // 改变 myRect 的anchors属性
 target:myRect
 anchors.top: window.top
 anchors.bottom:window.bottom
 }
 PropertyChanges {
 target: myRect
 anchors.topMargin: 10
 anchors.bottomMargin: 10
 }
 }
 ]
 MouseArea{
 anchors.fill: parent
 onClicked:window.state = "reanchored"
 }
}*/
//23. Behavior
/*Rectangle{
 id:rect
 width:100; height:100
 color:"red"
 // 针对宽度的动画
 Behavior on width{
 NumberAnimation{ duration: 1000}
 }
 MouseArea{
 anchors.fill: parent
 onClicked:rect.width == 50 ? rect.width = 100 : rect.width = 50;
 }
}*/
//24. SequentialAnimation 串行播放多个动画
/*Rectangle{
 id:rect1
 width:500; height:500
 Rectangle{
 id:rect
 color:"red"
 width:100; height:100
 //串行播放多个动画,先横向移动,在纵向移动
 SequentialAnimation{
 running:true;
 NumberAnimation{ target:rect; properties: "x"; to:50; duration: 1000}
 NumberAnimation{ target:rect; properties: "y"; to:50; duration: 1000}
 }
 }
}*/
//25. ParallelAnimation
/*Rectangle{
 id:rect1
 width:500; height:500
 Rectangle{
 id:rect;
 color:"red"
 width:100; height:100
 // 并行播放动画,同时横向和纵向移动
 ParallelAnimation{
 running: true;
 NumberAnimation{ target:rect; properties: "x"; to:50; duration: 1000}
 NumberAnimation{ target:rect; properties: "y"; to:50; duration: 1000}
 }
 }
}*/
//26. PropertyAnimation
/*Rectangle{
 id:rect
 width:100; height:100
 color:'red'
 states: State{
 name:'moved'
 PropertyChanges{ target:rect; x:100; y:100}
 }
 transitions: Transition {
 //属性动画 这里是当属性 x或y发生变化的时候,就播放这样一个动画
 PropertyAnimation{ properties: "x,y"; easing.type: Easing.InOutQuad}
 }
 MouseArea{
 anchors.fill: parent;
 onClicked:rect.state == "moved" ? rect.state="":rect.state="moved";
 }
}*/
//27. NumberAnimation
/*Rectangle{
 width:100; height:100
 color:"red"
 // 对当前item的x进行移动,目标移动到x = 50
 NumberAnimation on x{ to:50; duration: 1000}
}*/
//28. Vector3dAnimation
//29. ColorAnimation 颜色的过度
/*Rectangle{
 width:100; height:100
 color:"red"
 ColorAnimation on color { to: "black"; duration: 1000 }
}*/
//30. RotationAnimation 默认是绕z轴进行的旋转
/*Item{
 width:300; height:300
 Rectangle{
 id:rect
 width:150; height:100; anchors.centerIn: parent
 color:"red"
 smooth:true
 states: State{
 name:"rotated";
 PropertyChanges{ target:rect; rotation:180}
 }
 transitions: Transition {
 RotationAnimation{
 duration: 1000;
 direction: RotationAnimation.Counterclockwise
 }
 }
 MouseArea{
 anchors.fill: parent
 onClicked:rect.state = "rotated"
 }
 }
}*/
//31. ParentAnimation 一个切换父节点的动画,平滑的过度
/*Item{
 width:200; height:100;
 Rectangle{
 id:rect
 width:100; height:100; color:"red"
 }
 Rectangle{
 id:blueRect
 x:rect.width
 width: 50; height: 50
 color: "blue"
 states:State{
 name:"reparented"
 ParentChange{ target: blueRect; parent: rect; x:10; y:10}
 }
 }
 transitions:Transition{
 ParentAnimation{
 NumberAnimation{ properties: "x,y"; duration: 1000}
 }
 }
 MouseArea{
 anchors.fill: parent
 onClicked: blueRect.state == "reparented" ? blueRect.state="" : blueRect.state="reparented";
 }
}*/
//32. AnchorAnimation
/*Item{
 id:container
 width:200; height:200
 Rectangle{
 id:myRect
 width:100; height:100
 color: "red"
 }
 states: State{
 name:"reanchored"
 AnchorChanges{ target: myRect; anchors.right: container.right}
 }
 transitions: Transition{
 AnchorAnimation{ duration: 1000}
 }
 // 当控件加载完成后
 Component.onCompleted: container.state="reanchored"
}*/
//33. PauseAnimation 延迟效果
/*Item{
 id:container
 width:200; height:200
 Rectangle{
 id:myRect
 width:100; height:100
 color:"red"
 SequentialAnimation{
 running:true;
 NumberAnimation{target:myRect; to:50; duration: 1000; properties: "x"}
 PauseAnimation{ duration: 5000} // 延迟100毫秒
 NumberAnimation{target:myRect; to:50; duration: 1000; properties: "y"}
 }
 }
}*/
//34. SmoothedAnimation 平滑过度
/*Rectangle{
 width:500; height:400;
 color:"blue"
 Rectangle{
 width:60; height:60;
 x: rect1.x-5; y:rect1.y-5
 color:"green"
 Behavior on x{ SmoothedAnimation{ velocity: 200}}
 Behavior on y{ SmoothedAnimation{ velocity: 200}}
 }
 Rectangle{
 id:rect1
 width:50; height:50
 color:"red"
 }
 focus:true
 Keys.onRightPressed: rect1.x = rect1.x+100
 Keys.onLeftPressed: rect1.x = rect1.x - 100
 Keys.onUpPressed: rect1.y = rect1.y+100
 Keys.onDownPressed: rect1.y = rect1.y-100
}*/
//35. SpringAnimation 平滑的过度过程,在动画结束的时候有种弹性的效果
/*Item{
 width:300; height:300
 Rectangle{
 id:rect
 width:50; height:50
 color:"red"
 Behavior on x{ SpringAnimation{ spring:2; damping: 0.2}}
 Behavior on y{ SpringAnimation{ spring:2; damping: 0.2}}
 }
 MouseArea{
 anchors.fill: parent
 onClicked: {
 rect.x = mouse.x - rect.width/2
 rect.y = mouse.y - rect.height/2
 }
 }
}*/
//36. PropertyAction 主要是在动画过程中直接的改变一个属性
/*
transitions: Transition {
...
PropertyAction { target: theImage; property: "smooth"; value: true }
...
}
*/
/*
38. ScriptAction
在动画过程中嵌入脚本的调用
SequentialAnimation {
NumberAnimation { ... }
ScriptAction { script: doSomething(); }
NumberAnimation { ... }
}
*/
//39. Transition
/*Rectangle{
 id:rect
 width:100; height:100
 color:"red"
 MouseArea{
 id:mousearea
 anchors.fill: parent
 }
 states: State{
 name:"moved"
 when: mousearea.pressed
 PropertyChanges{ target: rect; x:50; y:50}
 }
 transitions: Transition{
 NumberAnimation{ properties: "x,y"; easing.type: Easing.InOutBack}
 }
}*/
//40. Binding
/*Item{
 width:300; height:300
 Text{ id:app; text:"xxxfa"}
 TextEdit{ x:app.width; id:myTextField; text:"Please type here..."}
 // 把myTextField和app的enteredText属性进行绑定
 Binding{target: app; property: "enteredText"; value:myTextField.text}
}*/
//41. ListModel 直接看效果
/*Rectangle{
 width:200; height:200
 ListModel{
 id:fruitModel
 ListElement{name: "Apple"; cost: 2.45}
 ListElement{name: "Apple"; cost: 2.46}
 ListElement{name: "Apple"; cost: 2.47}
 ListElement{name: "Apple"; cost: 2.48}
 ListElement{name: "Apple"; cost: 2.49}
 }
 Component{
 id:fruitDelegate
 Row{
 spacing: 10
 Text { text: name }
 Text { text: '$' + cost }
 }
 }
 ListView{
 anchors.fill: parent
 model:fruitModel
 delegate: fruitDelegate
 }
}*/
//42. ListElement请参照ListModel
//43. VisualItemModel 把可视化图元添加到链表试图
/*Rectangle{
 width:100; height:100
 VisualItemModel{
 id:itemModel
 Rectangle { height: 30; width: 80; color: "red" }
 Rectangle { height: 30; width: 80; color: "green" }
 Rectangle { height: 30; width: 80; color: "blue" }
 }
 ListView{
 anchors.fill: parent
 model: itemModel
 }
}*/
//44. VisualDataModel 看下面效果
/*Rectangle{
 width:200; height:100
 VisualDataModel{
 id:datamodl
 model:ListModel{
 ListElement { name: "Apple" }
 ListElement { name: "Orange" }
 }
 delegate: Rectangle{
 height:25
 width:100
 Text{text:"Name:"+name}
 }
 }
 ListView{
 anchors.fill: parent
 model:datamodl
 }
}*/
//45. Package具体请参考
//declarative/modelviews/package
//46. XmlListModel XmlRole
//从网络获取xml,暂时没有测试成功
//47. ListView
//参考 ListModel VisualDataModel
//48. GridView 看效果
/*Rectangle{
 width:200; height:400
 ListModel{
 id:fruitModel
 ListElement{name: "Apple"; cost: 2.45}
 ListElement{name: "Apple"; cost: 2.46}
 ListElement{name: "Apple"; cost: 2.47}
 ListElement{name: "Apple"; cost: 2.48}
 ListElement{name: "Apple"; cost: 2.49}
 }
 GridView{
 anchors.fill: parent
 model:fruitModel
 delegate: Column{
 Text{text:"name" +name}
 Text{text:"cost" + cost}
 }
 }
}*/
//49.PathView Path
/*Rectangle{
 width:200; height:400
 ListModel{
 id:fruitModel
 ListElement{name: "Apple"; cost: 2.45}
 ListElement{name: "Apple"; cost: 2.46}
 ListElement{name: "Apple"; cost: 2.47}
 ListElement{name: "Apple"; cost: 2.48}
 ListElement{name: "Apple"; cost: 2.49}
 }
 PathView{
 anchors.fill: parent
 model:fruitModel
 delegate: Column{
 Text{text:"name" + name}
 Text{text: "cost" + cost}
 }
 path:Path{
 startX: 120; startY: 100
 PathQuad{ x:120; y:25; controlX: 260; controlY: 75}
 PathQuad{ x:120; y:25; controlX: -20; controlY: 75}
 }
 }
}*/
//50.PathLine 具体的看运行的例子
/*Rectangle{
 width:200; height:400
 ListModel{
 id:fruitModel
 ListElement{name: "Apple"; cost: 2.45}
 ListElement{name: "Apple"; cost: 2.46}
 ListElement{name: "Apple"; cost: 2.47}
 }
 PathView{
 anchors.fill: parent
 model:fruitModel
 delegate: Column{
 Text{ text:"name"+name}
 Text{ text:"cost"+cost}
 }
 path:Path{
 startX: 150; startY: 120
 PathLine{x:300; y:80}
 PathLine{x:200; y:80}
 PathLine{x:100; y:120}
 }
 }
}*/
//51.PathQuad参考 PathView Path
//52.PathCubic
//53.PathAttribute 可以直接针对一些属性进行改变
/*Rectangle{
 width:200; height:400
 ListModel{
 id:fruitModel
 ListElement{name: "Apple"; cost: 2.45}
 ListElement{name: "Apple"; cost: 2.46}
 ListElement{name: "Apple"; cost: 2.47}
 }
 PathView{
 anchors.fill: parent
 model:fruitModel
 delegate:
 Item{
 id:delitem;
 width:80; height:80
 Column{
 Rectangle{
 width:40; height: 40
 scale:delitem.scale;
 color:"red"
 }
 Text{text:"name"+name}
 Text{text:"cost"+cost}
 }
 }
 path: Path {
 startX: 120; startY: 100
 PathAttribute { name: "Scale"; value: 1.0 }
 PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
 PathAttribute { name: "Scale"; value: 0.3 }
 PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
 }
 }
}*/
//54.PathPercent具体请看QML文档
//55.WebView
/*Rectangle{
 WebView {
 url: "http://www.nokia.com"
 preferredWidth: 490
 preferredHeight: 400
 scale: 0.5
 smooth: false
 }
}*/
//56 Column 横向排列
/*Rectangle{
 width:100; height:100
 // 纵向排列
 Column{
 spacing: 2
 Rectangle{ color:"red"; width:50; height:50}
 Rectangle{ color:"green"; width:50; height:50}
 Rectangle{ color:"blue"; width:50; height:50}
 }
}*/
//57 Row
/*Rectangle{
 Row{
 spacing: 3
 Rectangle{ color:"red"; width:50; height:50}
 Rectangle{ color:"green"; width:50; height:50}
 Rectangle{ color:"blue"; width:50; height:50}
 }
}*/
//58 Grid // 网格排列
/*Rectangle{
 width:100; height:100
 Grid{
 columns: 3
 spacing: 2
 Rectangle { color: "red"; width: 50; height: 50 }
 Rectangle { color: "green"; width: 20; height: 50 }
 Rectangle { color: "blue"; width: 50; height: 20 }
 Rectangle { color: "cyan"; width: 50; height: 50 }
 Rectangle { color: "magenta"; width: 10; height: 10 }
 }
}*/
//59 Flow
/*Rectangle{
 width:100; height:100
 Flow{
 spacing:2
 width:100; height:100;
 Rectangle { color: "red"; width: 50; height: 50 }
 Rectangle { color: "green"; width: 20; height: 50 }
 Rectangle { color: "blue"; width: 50; height: 20 }
 Rectangle { color: "cyan"; width: 30; height: 50 }
 Rectangle { color: "magenta"; width: 10; height: 10 }
 }
}*/
//60 Connections
/*下面是3中情况下会使用的,具体的不好翻译
Multiple connections to the same signal are required
有多个连接要连接到相同的信号时
Creating connections outside the scope of the signal sender
创建的连接在范围之外
Connecting to targets not defined in QML
创建的连接没有在QML中定义的
*/
/*Rectangle{
 width:100; height:100
 MouseArea{
 id:area
 anchors.fill: parent
 }
 Connections{
 target:area
 onClicked:{ console.log("ok");}
 }
}*/
//61 Component 组件是可以重用的QML元素,具体还是看QML的文档翻译不是很好
/*Item{
 width:100; height:100
 Component{
 id:redSquare
 Rectangle{
 color:"red"
 width:10
 height:10
 }
 }
 Loader{ sourceComponent: redSquare}
 Loader{ sourceComponent: redSquare; x:20}
}*/
//62 Timer
/*Item{
 width:200; height:40
 // 和QTimer 差不多
 Timer{
 interval: 500; running:true; repeat: true
 onTriggered:time.text = Date().toString()
 }
 Text{ id:time}
}*/
/*63 QtObject
他是不可见的只有objectName一个属性
通过这个属性我们可以在c++中找到我们想要的对象*/
//64 Qt 提供全局有用的函数和枚举,具体的看QML文档
//65. WorkerScript
//使用它可以把操作放到一个新的线程中,使得它在后台运行而不影响主GUI
//具体可以看QML中它的文档
//66. Loader
//可以参考Component
//还有QML中的文档
//67 Repeater 他可以创建很多相似的组件,QML中还有几个例子
/*Row{
 Repeater{
 model:3
 Rectangle {
 width: 100; height: 40
 border.width: 1
 color: "yellow"
 }
 }
}*/
//68 SystemPalette 具体看效果和文档
/*Rectangle {
 SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
 width: 640; height: 480
 color: myPalette.window
 Text {
 anchors.fill: parent
 text: "Hello!"; color: myPalette.windowText
 }
}*/
//69. FontLoader载入一种字体,可以是网络上的,也可以是本地的
/*Column {
FontLoader { id: fixedFont; name: "Courier" }
FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" }
Text { text: "Fixed-size font"; font.family: fixedFont.name }
Text { text: "Fancy font"; font.family: webFont.name }
}*/
//70 LayoutItem
//71 Scale 对缩放的控制
/*Rectangle{
 width:100; height:100
 color:"blue"
 Rectangle{
 x:50; y:50
 width:20; height:20
 color:'red'
 //这里是在当前矩形的中间位置沿x轴进行3倍缩放
 transform: Scale{ origin.x:10; origin.y: 10; xScale: 3}
 }
}*/
//72 Rotation
/*Rectangle{
 width:100; height:100
 color:"blue"
 // 绕位置25,25 旋转45度
 transform:Rotation{
 origin.x: 25; origin.y: 25; angle:45
 }
}*/
//73 Translate // 沿y轴正方向移动20个像素
Row{
 Rectangle{
 width: 100; height:100
 color:"blue"
 transform: Translate{ y:20}
 }
 Rectangle{
 width:100; height:100
 color:"red"
 // 沿y轴负方向移动20个像素
 transform: Translate{ y:-20}
 }
}
【QML】qml的属性绑定总结 一、引言 ​ 属性绑定是QML的核心特性,它允许我们指定不同对象属性之间的关系。当属性的依赖项值发生变化时,该属性将根据指定的关系自动更新。 ​ 在幕后,QML引擎监视属性的依赖项(即绑定表达式中的变量)。当检测到更改时,QML引擎重新计算绑定表达式并将新结果应用到属性中,从而实现对象对其他对象之间的之间的属性绑定。 ​ 总而言之,属性绑定关系存在于多个QML对象类型之间,是QML的核心特性之一。 ​ 二、进行qml属性绑定的方法 ​ 在QML中进行属性绑定主要三种方法: (1)使用冒号(:)进行属性绑定, 阅读详情

相关推荐

QML基础:QML属性绑定(Binding)

引言 用了N年的QWidget,因为项目需求而开始学习QML做一些动态的界面,下面开始记录学习QML的新路历程。 注:学习有误的望指点一二,不喜勿喷!!! QML属性绑定 属性绑定就是建立目标对象对其他对象的依赖关系,当其他对象值发生改变时,目标对象也会改变,自动更新属性,达到动态属性的效果。 绑定到不可访问的属性 有时,有必要将一个对象的属性绑定到另一个未由QML实例化的对象属性,例如C++导出到QML的类的属性。可以使用Binding类型来建立此依赖关系,将任何值绑定到任何对象的属性。 例如:在将“ap

fengyanyu68的博客 4099

QML 模型(ListModel)

LIstModel(列表模型)ListModel 是ListElement定义的简单容器,每个定义都包含数据角色。内容可以在 QML 中动态定义或显式定义。索引处的索引字典n从一个移动到索引索引处的。

qq_45303986的博客 5692

QML中的property属性使用说明

property属性: property是对象的属性,可以为其分配静态值或绑定到动态表达式。属性的值可以被其他对象读取。通常,另一个对象也可以修改它,除非特定的QML类型明确地禁止对特定property进行这样的修改。 定义property属性: 在c++中,也就是写cpp文件时,可以通过注册类的Q_PROPERTY来为类型定义属性,然后将该类型注册到QML类型系统。自定义property属性可以用下面的语法在QML文档中声明定义: [default] [required] [readonly] prope

a15322910600的博客 4186

QML学习(0) QML常用属性名称汇总

QML常用属性名称汇总,属性作为QML的一个核心概念,记住一些常用的属性,能很大程度上快捷编码

qianniulaoren的博客 525

QML类型编程:探索ListElement

ListElement是一种特殊的QML类型,用于在QML中定义列表元素。ListElement可以包含多个属性,每个属性代表列表中的一个字段。在本文中,我们将深入研究ListElement类型,并通过示例代码演示其用法。通过这些示例,我们可以看到ListElement在QML中的作用。在上面的代码中,我们创建了一个ListView,并使用ListModel作为其模型。在这个例子中,我们使用Text组件作为委托项,并利用ListElement中的属性来显示姓名和年龄。的属性,分别表示姓名和年龄。

ByteEchoX的博客 523

QML实现ListView的拖动排序

现有一种需求,就是用鼠标拖动某项,动态去改变某一项在ListView中显示的顺序位置,经过研究及实践实战,实现方式的核心代码如下: import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 Rectangle { width: 800 ...

草上爬的博客 7567

QML 与 C++交互 - 03 C++访问QML属性与函数

前言 详细说明 参考链接:http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html

星河的博客 7818

QML基本元素和属性

任何知识,都有自己的体系架构,掌握了体系架构,按图索骥的去学习的效率要远高于漫无目的的学习。这里我参照QML的知识框架和一些问题来对QML进行系统的总结。问题列表如下: 1.QML是什么? 2.为什么使用QML? 3.QML的基本语法? 4.QML的元素都有哪些? 1.QML是什么? QML是Qt推出的Qt Quick技术的一部分,是一种用于描述用户界面的类似html的声明式语言。它将用户界面分解成一些更小的元素,这些元素能够结合成一个组件。这点类似于json结构,每个对象既有自己的行为和属性同

yang1fei2的博客 9577

QML介绍,QML中的属性赋值

这里的width和height的值是固定的,除非你在后续的代码中显式地改变它们,否则它们不会自动更新。它们没有“绑定”到任何其他属性。

cyz322649的博客 1751

QML属性大总结

一、公共属性 QML里的各个可视化对象均继承与Item类,因此公共属性也就是Item的属性 注意:Item本身是不可视化的 1、标识符:id 功能:标识对象,方便引用 特点:必须唯一(可省略非必需),不然使用的时候语义不明 2、位置:x / y 功能:描述对象相对于父元素的位置 3、大小:width / height 功能:描述对象的大小:宽、高 4、层级顺序:z 功能:类似于CSS里的z-index属性,默认值为0; 详解:当不设置这个值的时候(或者两个元素的属性z值都相同时),默认是,后面一

贝勒里恩的博客 4036

时空数据建模的跨节点联邦图神经网络:KDD21 Cross-Node Federated Graph Neural Network for Spatio-Temporal Data Modeling

前言 联邦学习(FL)虽然已经被广泛研究,但是对复杂的时空依赖关系进行建模以提高预测能力仍然是一个开放的问题。此外目前最优的时空预测模型假定对数据的访问不受限制,忽略了对数据共享的限制。基于此,本文提了一个基于图联邦学习的时空数据模型 Cross-Node Federated Graph Neural Network (CNFGNN),该模型在跨节点联邦学习的约束下,使用基于图神经网络(GNN)的架构对底层图结构进行编码,属于结构化联邦的一种,每个本地模型利用私有数据进行学习,并保持分散性。CNFGNN

qq_56027260的博客 1814

QML中的附加属性

附加属性和附加信号处理程序是允许使用对象不可用的额外属性或信号处理程序来批注对象的机制。特别是,它们允许对象访问与单个对象特别相关的属性或信号。我们类型设计的时候要考虑单一职责,减少冗余,一些相关但又非必要的属性就可以拿出来作为附加属性。附加属性可以在不破坏类型定义的情况下扩展对象,其功能也可以用动态属性来实现。

龚建波 4030

Win10 + Linux 双系统删除(Linux)

删除Linux所使用的磁盘分区 进入此电脑->计算机->管理->磁盘管理

weixin_52247624的博客 948

QML 属性(Properties)

但不幸的是这样的代码阅读性很差。QML 对象由类型指定,一般与类型同名,名称以大写字母开头,后面跟一对大括号,在括号中包含了对象特性定义,包括 id、属性、信号、信号处理器、方法、附加属性和附加信号处理器等,当然也可以包含子对象。属性是对象的特性之一,可以分配一个静态的值或者绑定一个动态表达式,属性和值由一个冒号隔开,使用 “属性 : 值” 语法进行初始化,比如前面代码中。在 QML 语言的语法中,有一个附加属性的概念,这是附加到一个对象上的额外的属性。列表是包括在方括号内,以逗号分隔的多个元素的集合。

m0_73482095的博客 1418

AD20/Altium designer——如何进行DRC检查、冲突的错误如何改正

对于一个画完的PCB,我们常常需要进行DRC检查,确保板子的电器连接及制作工艺在设定规则的范围内,本篇将介绍如何对PCB进行后期DRC检查处理,确保电路板出现不必要错误。 1.DRC检查入口 2.DRC设置 3.错误分析 对于错误的内容,依据个人实际情况不同,其出现的原因都是因为与设计规则中的设定标准冲突,这里按遇到的错误进行修改讲解,其他错误同理。 4.常见错误分析及解决方法 (1) 解决方法:将未连接网络连接(...

嵌入式创客工坊的博客 5万+

直流电源EMI滤波器设计实战:从器件选型到PCB布局的完整指南

本文提供了一份直流电源EMI滤波器的完整实战设计指南。针对EMI噪声超标问题,文章深入剖析了差模与共模噪声的抑制原理,详细讲解了从电路拓扑、核心器件(如X/Y电容、共模电感)的选型计算,到决定性能成败的PCB布局艺术。重点强调了低阻抗路径、干净接地及输入输出隔离等关键布局原则,并分享了常见的调试坑点与排查方法,旨在帮助硬件工程师设计出真正有效的滤波器,确保电源系统通过EMC测试。

q9r0s的博客 651

QML对象属性

每个 QML 对象类型都有一组已定义的属性。对象类型的每个实例都是使用为该对象类型定义的属性集创建的。 一、id 属性 每个 QML 对象类型都只有一个 id 属性。 该属性由语言本身提供,不能被任何 QML 对象类型重新定义或覆盖。 id 可用于其他对象识别和引用该对象。 id 必须以小写字母或下划线开头,并且不能包含字母、数字和下划线以外的字符。 一旦创建了对象实例,其 id 属性的值就无法更改。 二、自定义属性 property 是QML自定义属性修饰符。 2.1、定义属性 通过注册

友善啊,朋友的博客 2360

4、I3C协议详解

I3C最初的设计目的是为移动设备创建一个能够使用多个传感器的单一接口。随着现代化移动设备对于传感器数量的增加以及对性能的提高,I2C和SPI已经达到了他们所能支持的临界点,而I3C的出现就是为了解决这一问题,I3C可以在同一根主线上支持更多的传感器设备,而且不会因为要支持中断或睡眠模式而增加额外的逻辑信号。I3C可以在更低功耗的情况下提供更快的传输速率,该特性的提升不止是对移动设备,对其他的嵌入式设备也都是很大的帮助。例如穿戴设备,需要在有限的物理空间中使用多个传感器并且要求更小的耗电。 一、简述..

迟子涵925的博客 2万+

QML学习(四) QML 中属性的分类及属性的使用详细说明

QML学习(四) QML 中属性的分类及属性的使用详细说明

qianniulaoren的博客 1797

DAC8568实战指南:如何用STM32实现8通道DAC精准控制(附代码)

本文提供DAC8568与STM32结合的实战指南,详细解析8通道16位DAC的精准控制方法。内容涵盖硬件连接、SPI配置、驱动层构建、时序调试及多通道同步输出等关键步骤,并附有经过验证的HAL库驱动代码,帮助工程师快速解决实际项目中的通信与输出稳定性问题。

weixin_29175469的博客 759

AMS TMF8820/21/28 SPAD 掩码和模式选择

为了实现最快的测距周期,将报告周期设置在测距周期以下的毫秒,以确保不会有等待时间。除了8X8固定了pixel的位置意外,其他模式客户可以设计自己的spad掩码,并将spad单独分配给通道。对于这些spad掩码,有一些约束。左下角提示红色代表光学中心,绿色方框表示单个spad,每个MP里可能有2X3个spad,也有2X5个spad,也有3X6+3个spad,这部分适配光学,最大的程度的利用spad区域。以下是几种预定义的spad掩码,非常灵活的配置,来适配各种3X3,4X4,8X8的模式选择。

dream it possible 707

QML属性

1.类型名称必须以大写字母开头 导入语法 一个QML文档可以在文件顶部具有一个或多个导入。导入可以是以下任意一项: 已注册类型的版本化名称空间(例如,通过插件) 在相对目录中包含qml类型定义的文件 一个JavaScript文件 各种import的通用形式如下: import Namespace VersionMajor.VersionMinor import Namespace ...

ddbo_821的专栏 956

【机器学习】推理时计算优化——思维链(Chain-of-Thought)与慢思考范式 第一章:基础理论与认知框架 第二章:计算优化技术与前沿方法

过程监督在数学推理中展现出显著优势,因其能够定位错误发生的具体步骤,而非仅在最终答案处提供稀疏反馈。然而,高质量过程标注的获取成本高昂,这催生了基于自动验证器的近似方法。

VectorShift的博客 83

【qml】 QML属性绑定的三种方法

在属性绑定中,静态值的赋值将删除对象之间的绑定。即带有绑定的属性会根据需要自动更新。但是,如果绑定后再从JavaScript语句中为该属性分配一个静态值,那么该绑定将被删除。Window {id : button x : 270 y : 253 text : qsTr("点击我") onClicked : {//如果此点击事件处理函数得以执行,那么text1的text属性将被重新赋值为“999”。此后 //text1对象将与slider对象解除绑定。...

iriczhao的博客 1419

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

QML中的default默认属性

1.认识default属性 QML的default属性是我们一直在用,但一开始却没注意的机制(我理解为语法糖)。先看文档说明: An object definition can have a single default property. A default property is the property to which a value is assigned if an object is declared within another object's definition without

龚建波 2767

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

上一篇: QML Image获取资源路径的细节
下一篇: QML Item详解
艺丢丢
博客等级 码龄13年 16粉丝 52原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址