QML(02)——重复性组件Repeater
实现效果
//UnsoundRow.qmlimport QtQuick 2.0Item {id: unsoundRowproperty string activeOption: "生芽粒"Row {anchors.horizontalCenter: parent.horizontalCenteranchors.top: parent.topanchors.topMargin: 70Repeater {model: ["生芽粒", "生霉粒", "虫蚀粒", "破损粒", "病斑粒", "黒胚粒", "异种粮", "有机杂", "无机杂", "正常颗粒"]UnsoundOption {text: modelData//activeOption 改变时,组件属性表达式 会实时变化optionEnabled: unsoundRow.activeOption === textMouseArea {anchors.fill: parentonClicked: {unsoundRow.activeOption = parent.textconsole.log("activeOption = ", unsoundRow.activeOption)}}}}}
}
//UnsoundOption.qmlimport QtQuick 2.0Item {id: unsoundOptionimplicitWidth: 150implicitHeight: 50property alias text: label.textproperty bool optionEnabled: falseRectangle {id: rectanglewidth: parent.widthheight: parent.heightborder.color: "#3a3a3a"border.width: 1radius: 10Text {id: labelanchors.centerIn: parentfont.pixelSize: 20color: "#000000"text: "选项"}}onOptionEnabledChanged: {if (unsoundOption.optionEnabled === true) {rectangle.color = "#1e90ff"rectangle.border.color = "#ffffff"label.color = "#ffffff"label.font.bold = true} else {rectangle.color = "#ffffff"rectangle.border.color = "#000000"label.color = "#000000"label.font.bold = false}}
}
QML(02)——重复性组件Repeater相关推荐
- QML中的组件——QML
转自:https://blog.csdn.net/douzhq/article/details/81046681 本篇文章介绍一下QML中的组件,Component 1. 使用Component在QM ...
- QML学习 QML文件当做组件使用
QML学习:QML文件当做组件使用 本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 参考文档<<Qt及Qt Quick开发实战精解.pdf& ...
- QML delegate中使用Repeater
在QML界面设计例如ListView中,通过设计delegate来显示代理model中的数据,在delegate中使用属性绑定的方式将model中对象的值显示出来,但如果delegate中使用了Rep ...
- Qt Qml动态创建对象/组件的两种方式
Qml动态创建对象有两种方式: a.使用Loader b.使用javaScript 1.Loader加载机制: 加载过程: 通过source,来加载qml文件. 通过sourceComponent,来 ...
- QML之Rectangle组件
Rectangle QML提供了很多基础的图形化组件,比如Rectangle.Text.Image.TextInput.TextEdit.Shape等,它们都继承于根组件Item.使用它们需要导入Qt ...
- QML之TextEdit组件
TextEdit TextEdit组件与TextInput类似,不过它支持用户输入多行文本,甚至可以通过textFormat属性支持富文本或者Markdown格式的文本内容. TextEdit {id ...
- 微信小程序_基础组件学习02
微信小程序_基础组件学习02 swiper组件 swiper是滑块容器,也就是手机端的轮播图. swiper组件有两部分组成swiper和swiper-item. swiper-item需要放在swi ...
- QML进阶--Loader实现组件的动态切换
在QML学习和开发过程中,看到Loader的官方介绍之后,发现Loader就是用来动态加载一个qml或者component的容器. 有一个问题在我脑海里冒了出来:loader加载一个qml或者一个组件 ...
- QML 基本文本输入组件TextInput、TextField、TextEdit、TextArea
0.前言 Qt Quick 提供了两个基本的文本输入组件 TextInput 和 TextEdit ,在 Control 模块中提供了以前面两种为基类的 TextField 和 TextArea .其 ...
最新文章
- [翻译]在GridView中插入新记录
- Synchronization 进程锁
- Loopback測试软件AX1用户手冊 V3.1
- OJ1004: 三位数的数位分离
- Win7、Ubuntu双系统正确卸载Ubuntu系统
- python *args **kargs
- 数据密集型应用系统设计--数据复制
- Lua基础(字符处理)
- 基于Laravel+VueJS实战开发WebAPP
- 内网通v3.1.2141无捆绑绿色官方版
- 【开篇】抽象代数的历史背景与内容总览
- Pymol教程--Caver插件 研究蛋白通道
- 日照分析的计算机精度,日照分析计算精度(时间间隔)的粗探
- APP响应时间和响应速度测试
- 深信服测试开发日常实习岗位一面凉经(来自李某)
- 计算机不显示苹果手机储存,苹果备份电脑显示内存不足怎么办
- 怎样利用模板拼接字符串
- 东软慧聚助力汽车“芯”节能减排
- rk3288 调试dvp摄像头_RK3288 - 双路摄像头的硬件外接实现
- 探索者系列_百度百科