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

即可解决问题

相关推荐
linuxxx1102 小时前
正则匹配应用小案例
数据库·正则表达式
威风的虫5 小时前
常用的正则表达式
正则表达式
Lv11770086 小时前
Visual Studio中的正则表达式
ide·笔记·正则表达式·c#·visual studio
故事不长丨14 小时前
C#正则表达式完全攻略:从基础到实战的全场景应用指南
开发语言·正则表达式·c#·regex
YxVoyager1 天前
Qt C++ :QRegularExpression 正则表达式使用详解
c++·qt·正则表达式
laocooon5238578862 天前
正则表达式的全面介绍
正则表达式
ben9518chen2 天前
正则表达式
正则表达式
半路_出家ren2 天前
17.python爬虫基础,基于正则表达式的爬虫,基于BeautifulSoup的爬虫
网络·爬虫·python·网络协议·正则表达式·网络爬虫·beautifulsoup
Good_Starry3 天前
Java——正则表达式
java·开发语言·正则表达式
@zulnger3 天前
正则表达式
数据库·正则表达式