Qt笔记-qml-radionButton
2017-10-19 14:37
387 查看
qml自定义RadioButton (暂时只做了双态)
使用:
import QtQuick 2.0 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 Item { id: item property string text: "" property bool checked: true // 单选框框风格组件 Component{ id: radioStyle; RadioButtonStyle{ indicator: Rectangle{ implicitHeight: radioButtonImage.height; implicitWidth: radioButtonImage.width; color: "#00000000" Rectangle{ id: myCheck anchors.fill: parent; state: { if ( control.checked ) state: "radioCheck"; else state:"radioNoCheck"; } color: "#00000000" property string imageSource: "" property string imageChecked: "qrc:/image/RadioButtonChecked.png" property string imageNoChecked: "qrc:/image/RadioButtonNoChecked.png" Image { id: radioButtonImage source: myCheck.imageSource } states: [ State { name: "radioCheck" PropertyChanges { target: myCheck imageSource:imageChecked; } } ,State { name: "radioNoCheck" PropertyChanges { target: myCheck imageSource:imageNoChecked; } } ] } } label:Text{ //color: control.activeFocus?"blue":"black"; color: "#444444" font.pointSize: 14 text:control.text; } } } //具体单选框 RadioButton{ text: item.text; checked: item.checked; focus: true; activeFocusOnPress: true; style:radioStyle; } }
使用:
CRadionButton{ anchors.top: rect.bottom; anchors.topMargin: 4; anchors.left: rect.left; anchors.leftMargin: 10; text: "是否可用" checked: false }
相关文章推荐
- Qt界面UI之QML初见(学习笔记四)
- Qt界面UI之QML初见(学习笔记四)
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- Qt笔记-qml-button
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- Qt笔记-qml-lineEdit
- QML笔记整理——在Qt/C++应用中使用QML
- qt_qml开发笔记
- Qt5+QML笔记
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- QT6410移植linux-2.6.39 笔记(一)-搭建开发板环境
- QT笔记
- 如何在Qt和QML之间建立信号槽链接
- opencv安装(WinXp平台下,Qt环境)笔记之二—测试opencv库安装成功
- Qt Model/View 学习笔记 (三)
- QT笔记整理
- 学习笔记:一个Qt小程序,在开发板上运行成功
- Opencv Qt 学习笔记(三) 级联器的训练
- QML笔记点滴