Qt笔记-qml-lineEdit
2017-10-18 14:32
411 查看
qml 自定义 LineEdit
import QtQuick 2.0 FocusScope{ id: wrapper property DoubleValidator doubleVal: DoubleValidator{ bottom: 10.00 top:50.01 decimals: 4 //保留小数点位数 //notation: DoubleValidator.StandardNotation //notation: DoubleValidator.ScientificNotation } property string hintStr: "hello world" Rectangle{ id: rect width: 110 height: 39 //anchors.fill: parent border.color: "#C1C1C1" border.width: 1 color: "white" radius: 2 //半径 TextInput{ id: input anchors.top: parent.top anchors.bottom: parent.bottom anchors.left: parent.left;//iconArea.right anchors.leftMargin: 6 anchors.right: parent.right anchors.rightMargin: 9 horizontalAlignment: TextInput.AlignLeft verticalAlignment: TextInput.AlignVCenter font.pointSize: 14 color: "#444444" clip: true //只接受5-120之内的值 //validator: IntValidator{bottom: 5;top:120} //使用外面设定的值 validator: doubleVal Text { id: placeHold font: input.font color: "#d0d0d0" opacity: input.length ? 0 : 1 //当默认提示使用 Behavior on opacity{ NumberAnimation{ duration: 300 } } anchors.fill: parent verticalAlignment: TextInput.AlignVCenter text: hintStr //使用传进来的提示字符 } } } } 使用例子: LineEdit { x: 110 hintStr: qsTr("只能输数字") doubleVal: DoubleValidator{ bottom: 10.00 top:50.01 decimals: 5 //保留小数点位数 notation: DoubleValidator.StandardNotation //notation: DoubleValidator.ScientificNotation } }
相关文章推荐
- QT笔记之QLineEdit自动补全以及控件提升
- qt_qml开发笔记
- Qt笔记-qml-button
- Qt5+QML笔记
- Qt笔记-qml-radionButton
- QT笔记(3)——Qt的lineEdit和textEdit的右键菜单汉化
- Qt笔记-3-LineEdit中使用正则表达
- QML笔记整理——在Qt/C++应用中使用QML
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- qt学习笔记之QLineEdit
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- Qt界面UI之QML初见(学习笔记四)
- Qt界面UI之QML初见(学习笔记四)
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- QML与c++交互学习笔记(八) qt c++直接调用QML中的函数, 直接设置属性
- Qt学习笔记3-lineEdit和textEdit
- QT lineedit 小疑问
- QML和c++(Qt)相互传值
- Qt 两个lineEdit 判断焦点问题
- install Qt5.4 creater in ubuntu —— opencv 学习笔记 ( 1 )