在QTavleView中添加QLineEdit(用正则表达式校验输入的IP地址)
发布时间:2020-12-14 06:38:49 所属栏目:百科 来源:网络整理
导读:在QTableView中添加QLineEdit,并且该QLineEdit是需要填入IP地址,因此输入的数据必须遵循IP地址的规则。这时可以使用QT中的委托。 委托的一篇文章http://blog.csdn.net/hello_world_lvlcoder/article/details/59478712 QLineEdit *editor = new QLineEdit(p
在QTableView中添加QLineEdit,并且该QLineEdit是需要填入IP地址,因此输入的数据必须遵循IP地址的规则。这时可以使用QT中的委托。 委托的一篇文章http://blog.csdn.net/hello_world_lvlcoder/article/details/59478712 QLineEdit *editor = new QLineEdit(parent); QRegExp rx("^((2[0-4]d|25[0-5]|[01]?dd?).){3}(2[0-4]d|25[0-5]|[01]?dd?)$"); editor->setValidator(new QRegExpValidator(rx,parent)); editor->setInputMask("000.000.000.000;0");//必须加;0否则前面的正则表达式失效,;0”表示删除时默认填充为0 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |