引用第1楼paranoid于2010-05-04 16:27发表的 :可以使用正则表达式验证器QRegExpValidatorQRegExp rx("((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)");QRegExpValidator v(rx, 0);QLineEdit le;le.setValidator(&v);
引用第3楼iiiyyyhhhsss于2010-05-05 14:05发表的 :原来楼上只需要多加一句即可:QRegExp rx("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)");QRegExpValidator v(rx, 0);QLineEdit le;le.setValidator(&v);le.setInputMask("000.000.000.000");.......
引用第4楼iiiyyyhhhsss于2010-05-05 16:30发表的 : 发现这个还是有问题,setInput()和setValidator好像不能同时使用....同时使用的话,正则表达式就没有效果了...