QM关于Repeater的使用
来源:互联网 发布:学美工设计培训班 编辑:程序博客网 时间:2024/05/01 13:32
我们在使用qml画界面的时候会经常用到很多重复的组件,下面我们来了解一种可以快速布局的的Repeater
:下面是我写的一个实例
main.aml
import QtQuick 2.7import QtQuick.Controls 1.5import QtQuick.Layouts 1.0ApplicationWindow { visible: true width: 640 height: 480 id:root Rectangle{width: root.width; height: root.height;color: "#3A3250"; Column { anchors.fill: parent spacing: 10 Repeater { id: mainRepeater model: 3 delegate: IOcase{//IOLNormalCase这是一个qml id: iolCalItem width: root.width height: (root.height ) / 3 modelType: Math.pow(2,index) viewModel: iolCalItem.modelType == 1 ? 7 : 6 } } } }}
IOcase.qml
import QtQuick 2.0Item { id: root property int modelType: 1 property alias viewModel: listView.model Text {//table type horizontalAlignment: Text.AlignLeft text: modelType & 1 ? qsTr("Formula Param.") : modelType & 2 ? qsTr("Emme Table") : qsTr("IOL Ame Table") width: root.width / 6 } Rectangle { anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right width: root.width / 6 * 5 color: "transparent" border.width: 2 border.color: "#545454" ListView { id: listView anchors.fill: parent anchors.margins: parent.border.width interactive: false delegate: Rectangle { color: listView.currentIndex == index ? "#3F6597" : "transparent" width: listView.width height: listView.height / listView.count Row {//水平布局 anchors.fill: parent Text { width: parent.width / 5 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: "bb" Rectangle { color: "#545454" anchors.right: parent.right width: 2 height: parent.height } } Text { width: parent.width / 5 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: "00" Rectangle { color: "#545454" anchors.right: parent.right width: 2 height: parent.height } } Text { width: parent.width / 5 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text:"00" Rectangle { color: "#545454" anchors.right: parent.right width: 2 height: parent.height } } Text { width: parent.width / 5 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: "00" Rectangle { color: "#545454" anchors.right: parent.right width: 2 height: parent.height } } Text { width: parent.width / 5 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: "00" } } Rectangle { color: "#545454" width: parent.width height: 2 anchors.bottom: parent.bottom visible: index != listView.count - 1 }//颜色框 MouseArea {//鼠标选择点击事件 anchors.fill: parent onClicked: { if (listView.currentIndex != index) { listView.currentIndex = index } } } } } }}
贴一个结果:
0 0
- QM关于Repeater的使用
- 关于Repeater控件的使用
- 关于Repeater控件的使用
- 关于Repeater控件的使用
- 关于Repeater控件的使用
- 关于Repeater控件的使用
- 关于Repeater控件的使用
- 关于repeater的全选
- 使用QM的外部工具功能编译代码
- repeater 潜逃 repeater ItemDataBound的使用
- qm
- 使用Repeater的Template
- Repeater控件的使用
- Repeater控件的使用
- Repeater的初步使用
- Repeater控件的使用
- Repeater的使用 前台
- Repeater的使用
- Corn Fields 状压DP
- 图片压缩无bug版
- #if ... #endif
- 如何弄清二叉树前序中序后序遍历的顺序
- 听译letters live
- QM关于Repeater的使用
- 访问localhost时You don't have permission to access / on this server.
- 基于 Facebook Redex 实现 Android APK 的压缩和优化
- windows libevent使用 客户端+服务端
- Notes on tensorflow(六)variable_scope
- 利用File来储存和读取
- Spring mvc 和 CXF 搭建SOAP环境
- JavaScript学习笔记17-与或非处理复杂的条件
- 打开指定文件夹并批量修改文件名(python)