QT6中对正则部分做了相关修改
QString str = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
this->m_OutputLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(str)));
this->m_OutputLineEdit->setInputMask("000.000.000.000");
this->m_InputLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(str)));
this->m_InputLineEdit->setInputMask("000.000.000.000");

在QT6中,对于正则表达式处理有了一些更新。文章展示了如何使用QString定义一个匹配IPv4地址的正则表达式,并应用于QLineEdit的输入验证,通过QRegularExpressionValidator进行设置。同时,使用000.000.000.000作为输入掩码,确保输入符合IP地址格式。
328

被折叠的 条评论
为什么被折叠?



