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);

即可解决问题

相关推荐
2401_827499992 天前
python项目实战11-正则表达式基础
python·mysql·正则表达式
互联网散修2 天前
零基础鸿蒙应用开发第三十三节:正则表达式基础与应用
华为·正则表达式·harmonyos
bukeyiwanshui2 天前
20260414 正则表达式及shell三剑客
数据库·mysql·正则表达式
坐吃山猪3 天前
Python09_正则表达式
开发语言·python·正则表达式
橙露4 天前
Python 正则表达式:文本清洗与信息提取速通手册
python·正则表达式·easyui
XiaoQiao6669996 天前
pytnon中正则表达式小题详解
python·正则表达式
gCode Teacher 格码致知6 天前
Python基础教学:正则表达式中的忽略大小写以及符号“-“的问题-由Deepseek产生
python·正则表达式
ths5126 天前
Python 正则表达式实战指南:从入门到精通(12 个高频案例)(三)
python·正则表达式
ths5127 天前
Python 正则表达式学习笔记(小白超详细版)(一)
python·正则表达式
kcuwu.9 天前
Python 正则表达式从入门到实战
数据库·python·正则表达式