質問

I'm looking for the way to limit line edit to accept only alphanumeric characters, dash and underscore (in whole line could be only one dash and one underscore), without spaces. I was looking at RegExp, but then I left this option, because I found some blog post which is explaining that RegExp is really slow. Now I don't know what is best way to limit line edit, so the output would be like I want.

What do you recommend me?

役に立ちましたか?

解決

You should read function QLineEdit::setValidator documentation and class QValidator documentation. You can define your own validator class (that inherits QValidator) and pass its object instance to QLineEdit object (using setValidator function).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top