如何让qlineedit->settext()
只接受.ma类型的文件?
答案 0 :(得分:2)
我假设您希望字符串在<filename>.ma
中的格式为QLineEdit
。
如果是这种情况,您可以使用
void QLineEdit::setValidator ( const QValidator * v )
此外,QRegExpValidator
可以验证特定字符串。
我对RegExp并不熟悉,但我猜QRegExp rx("*.ma");
因为正则表达式适用于你的情况。
希望它有所帮助...