Question

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?

Was it helpful?

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(" ");

OTHER TIPS

If what you want is to have a default text when the widget is empty, use the setPlaceholderText(QString)

If you want to just set a initial value, then do it in the constructor of your app/widget/class with setText(QString)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top