Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top