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 .其 ...
最新文章
- fpga经典设计100例_图解运放电路/OP放大电路设计/OP放大器应用技巧100例
- 软考高项之学习笔记——质量成本概念
- mysql DATE_FORMAT 年月日时分秒格式化
- 你真的了解NSNotificationCenter吗?
- leetcode 415. 字符串相加(Java版)
- android 隐藏所有 fragment,Android 隐藏Fragment
- Python爬取王者荣耀皮肤
- ubuntu系统下hbase数据库的安装和使用,hbase配置文件详解
- 核心JavaScript——词法结构
- intra调用order
- 【软件分享】天若OCR文字识别V4.48(翻译功能免费)
- BP神经网络代码和原理
- python用什么编译器-python用什么编译器
- Kinect使用系列
- android banner指示器高度,Android 广告轮播 -ConvenientBanner 指示器大小、bottomMargin,leftMarfin的修改。...
- mac服务器文件夹权限设置密码,如何在Mac os优胜美地给文件和文件夹加密
- uniapp 分享功能(app , 小程序)
- 百位数,十位数,个位数的求法
- 基于51单片机的数码录音放音系统设计
- 【python】pygame实现植物大战僵尸小游戏(附源码 有注释)