加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

QML中正则式的应用

发布时间:2020-12-14 04:24:01 所属栏目:百科 来源:网络整理
导读:QML 中RegExpValidator(正则表达式)简单例子 2012-08-28 21:36:19 分类: 嵌入式 import QtQuick 1 . 1 Rectangle { width : 360 height : 360 TextInput anchors . centerIn : parent text "1" validator : RegExpValidator { regExp : / [ 0 - 5 ] - 9 [
QML 中RegExpValidator(正则表达式)简单例子 2012-08-28 21:36:19

分类:嵌入式


  1. importQtQuick 1.1

  2. Rectangle{
  3. width:360
  4. height:360
  5. TextInputanchors.centerIn:parent
  6. text"1"
  7. validator:RegExpValidator{regExp:/[0-5]-9[.}
  8. }
这样可以限制输入……
第一个数为:0-5
第二个数为:0-9
第三个数为:0-5
第四个数为:.
第五个数为:0-9

同样也可以输入限制字符串:
  1. validator/love}
如果要用于限制数大小我认为还是 DoubleValidator更实际一点:

:DoubleValidatorid:intval;decimals:1;bottom:380top:500;notation.StandardNotation}
结果是:输入在380-500,小数位:1;
==========================================================================
2012年8月30日19:41:32 更新

^[1{1,2}$}
结果是只能输入:1-99,具体的含义:[1-9]每位范围1-9;{1,2}位数1-2(总共2位);

()?|^1^2-3^24]0}
结果是只能输入:1-24,允许有一位小数

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读