PDA

View Full Version : Confirm text on QLineEdit



hassinoss
14th April 2014, 14:55
How can i ensure that a text in qlineEdit is not a space.
I tried with QRegExp in vain.

ChrisW67
15th April 2014, 01:32
What do you mean "is not a space"? Do you mean not a single space character? Do you mean must only contain non-space characters? Cannot be only space characters but can contain spaces? Can never enter space characters or must not contain spaces when isAcceptable() is called?

Radek
15th April 2014, 04:44
If you need to make sure that the string is non-blank then get the string and apply trimmed() on it. If the result is an empty string then the original string contained only blanks, tabs, carriage returns and similar characters. If the result isn't empty then the result is the original string with blanks (and similar characters) removed both from left and from right. The resulting string can contain blanks inside.