实现效果

//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相关推荐

  1. QML中的组件——QML

    转自:https://blog.csdn.net/douzhq/article/details/81046681 本篇文章介绍一下QML中的组件,Component 1. 使用Component在QM ...

  2. QML学习 QML文件当做组件使用

    QML学习:QML文件当做组件使用 本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 参考文档<<Qt及Qt Quick开发实战精解.pdf& ...

  3. QML delegate中使用Repeater

    在QML界面设计例如ListView中,通过设计delegate来显示代理model中的数据,在delegate中使用属性绑定的方式将model中对象的值显示出来,但如果delegate中使用了Rep ...

  4. Qt Qml动态创建对象/组件的两种方式

    Qml动态创建对象有两种方式: a.使用Loader b.使用javaScript 1.Loader加载机制: 加载过程: 通过source,来加载qml文件. 通过sourceComponent,来 ...

  5. QML之Rectangle组件

    Rectangle QML提供了很多基础的图形化组件,比如Rectangle.Text.Image.TextInput.TextEdit.Shape等,它们都继承于根组件Item.使用它们需要导入Qt ...

  6. QML之TextEdit组件

    TextEdit TextEdit组件与TextInput类似,不过它支持用户输入多行文本,甚至可以通过textFormat属性支持富文本或者Markdown格式的文本内容. TextEdit {id ...

  7. 微信小程序_基础组件学习02

    微信小程序_基础组件学习02 swiper组件 swiper是滑块容器,也就是手机端的轮播图. swiper组件有两部分组成swiper和swiper-item. swiper-item需要放在swi ...

  8. QML进阶--Loader实现组件的动态切换

    在QML学习和开发过程中,看到Loader的官方介绍之后,发现Loader就是用来动态加载一个qml或者component的容器. 有一个问题在我脑海里冒了出来:loader加载一个qml或者一个组件 ...

  9. QML 基本文本输入组件TextInput、TextField、TextEdit、TextArea

    0.前言 Qt Quick 提供了两个基本的文本输入组件 TextInput 和 TextEdit ,在 Control 模块中提供了以前面两种为基类的 TextField 和 TextArea .其 ...

最新文章

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

热门文章

  1. 【文末有惊喜!】Hive SQL血缘关系解析与应用
  2. ZT:150条毒鸡汤
  3. 【五一创作】深度学习
  4. 一小时就做好的python游戏实战:打牌小游戏,好玩归好玩,注意别玩上瘾了哟~~
  5. 快递查询接口 常用快递单号查询API示例分享
  6. 2021年oppo哲库数字IC岗位手撕代码真题(含:握手信号、自动售卖机、序列发生器、根据RTL写verilog)
  7. ITN网络课程笔记(三)
  8. 划分问题之泰森多边形简介
  9. uv平板打印机墨水参数
  10. 我的微语录周记2012-02-06---2012-…