문제

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