1

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?

user1257255
  • 1,161
  • 8
  • 26
  • 55

1 Answers1

3

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).

Serge Dundich
  • 4,221
  • 2
  • 21
  • 16