Pregunta

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?

¿Fue útil?

Solución

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

Otros consejos

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)

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