QT6找不到QRegExpValidator类问题解决办法

QT做正则表达式时,移植的qt5程序,然后报错

经过一番研究

qt6没有QRegExpValidator了但是有替代方法

QT5程序

cpp 复制代码
    QRegExp rx("^((99)|(9[0-9]\\d)(\\.\\d{1,2})?|([1-9]\\d)(\\.\\d{1,2})?|([1-9])(\\.\\d{1,4})?|0(\\.\\d{1,4})?)$ ");
    QRegExpValidator *pReg = new QRegExpValidator(rx, this);
    ui->volHight->setValidator(pReg);

QT6替换为

cpp 复制代码
    QRegularExpression  rx("^((99)|(9[0-9]\\d)(\\.\\d{1,2})?|([1-9]\\d)(\\.\\d{1,2})?|([1-9])(\\.\\d{1,4})?|0(\\.\\d{1,4})?)$ ");
    QValidator  *pReg = new QRegularExpressionValidator(rx, this);
    ui->volHight->setValidator(pReg);

即可解决问题

相关推荐
坐吃山猪8 小时前
Python09_正则表达式
开发语言·python·正则表达式
橙露14 小时前
Python 正则表达式:文本清洗与信息提取速通手册
python·正则表达式·easyui
XiaoQiao6669993 天前
pytnon中正则表达式小题详解
python·正则表达式
gCode Teacher 格码致知3 天前
Python基础教学:正则表达式中的忽略大小写以及符号“-“的问题-由Deepseek产生
python·正则表达式
ths5123 天前
Python 正则表达式实战指南:从入门到精通(12 个高频案例)(三)
python·正则表达式
ths5124 天前
Python 正则表达式学习笔记(小白超详细版)(一)
python·正则表达式
kcuwu.6 天前
Python 正则表达式从入门到实战
数据库·python·正则表达式
羊小蜜.6 天前
Mysql 07: 正则表达式查询(REGEXP)全解
数据库·mysql·正则表达式
Dxy12393102166 天前
正则表达式如何匹配提取文章日期
数据库·mysql·正则表达式
Dxy12393102169 天前
Python正则表达式判断姓名:详细解析
python·mysql·正则表达式