View Full Version : Which widget to select in QT designer to display a number

5th July 2017, 18:26
I'm building a GUI using the QT designer 5.9. This GUI will be used to get a float value from the user then two radio buttons to ask what conversion they need to perform then display the result. I'm not sure which widget to select for my display. Does this really matter much or would I need to use a very specific widget?

For information this UI will be converted to python as that's what my conversion tool is written in.

Thank you for any information or help and sorry for the n00b question.

5th July 2017, 18:51
I'm not sure which widget to select for my display.

You have two choices: use a QLabel or a QLineEdit (with editing disabled: QLineEdit::setReadOnly()). It depends on how you want the output to appear. If you use a standard QLabel, it will look like plain old text on the background of your main UI widget. If you use QLineEdit, it will look like an edit box (with a frame around the text).

In either case, you should user QString::number() to format the text the way you want it to appear, then use the appropriate setText() call to display it in the result widget.

The translation from C++ syntax to Python syntax is straightforwward.

5th July 2017, 22:14
Thanks very much. I've got the UI done now to complete the rest of the script.