开发者

Restricting qlineedit by file type

开发者 https://www.devze.com 2023-01-11 15:10 出处:网络
How is it possible to have qlineedit->settext开发者_Python百科() to accept file of type .ma only?I assume you want the string to be of the format <filename>.ma in the QLineEdit.

How is it possible to have qlineedit->settext开发者_Python百科() to accept file of type .ma only?


I assume you want the string to be of the format <filename>.ma in the QLineEdit.

If that's the case, you can use

void QLineEdit::setValidator ( const QValidator * v )

Also, QRegExpValidator can validate for specific strings.

I am not well versed with RegExp but I guess QRegExp rx("*.ma"); as an Regular Expression will be fine for your case.

Hope it helps...

0

精彩评论

暂无评论...
验证码 换一张
取 消