Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved]How to remove the spaces before and after two words but not remove the space between the two words?
I have difficulty in solving the above problem.
I had encountered a problem in removing the space between the words.
For example, when I put " <spaces> Hi everyone <spaces> ", I want only to get the string "Hi everyone".
I came across this function, "setInputMask".
But it still doesn't solve my problem.
Can anyone help me?
Maybe you can give some clue or explain on how exactly this function works?
Btw, this is my code snippet:
if (ui->lineEdit->text()== NULL)
Are you thinking of something like QString::trimmed() ?
Thanks for the suggestion.
That's really helps me. :)
andre last edited by
There is also QString::simplified(). That one does a bit more, in that it also removes things like double spaces between words (reduces them to a single space), as well as trimming.
ok, thanks Andre...