PDA

View Full Version : Line edit accept only alphanumeric characters, dash and underscore



janck
8th June 2013, 15:38
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?

wysota
8th June 2013, 16:45
Unless you are going to be filling a few thousand fields per second, you can safely use QRegExpValidator. Otherwise subclass QValidator and do the validation yourself.