Search code examples
qtqlineedit

How to set QLineEdit default text to one space?


I entered one space as a QLineEdit's text in the Qt Creator GUI Designer. I can see that the space is there in the designer wiew, but if I compile and run it, the space disapears. I want this space to be a QLineEdit's default text, how can set it, or tell Qt to do not delete that one space?


Solution

  • My guess is that space disappears because UIs are stored as XML and nodes consisting only of whitespace are strippd (see this question).

    But you can set the space to the QLineEdit in the window's constructor:

    ui->lineEdit->setText(" ");