Which Widget to use to display simple text lines?
-
wrote on 13 Mar 2022, 22:34 last edited by
Hi,
I need a Widget to display a number of simple text lines.
There should be no scrolling.
I do not need to edit the text.
It would be nice if I could control line spacing such that a fixed number of lines fits the size of the Widget.Is there a Widget suitable for this?
Or should I draw the strings myself on some canvas or so? -
wrote on 13 Mar 2022, 23:06 last edited by mpergand
Hi,
Why not use aQTextView? QTextEdit of courseIt would be nice if I could control line spacing such that a fixed number of lines fits the size of the Widget.
For that I'll simply put QLabels in a QVBoxLayout.
-
wrote on 13 Mar 2022, 23:41 last edited by
Isn't QTextView obsolete? I only see the QTextEdit and I do not need edit functionality. I'm afraid this will slow down drawing.
-
Isn't QTextView obsolete? I only see the QTextEdit and I do not need edit functionality. I'm afraid this will slow down drawing.
-
Isn't QTextView obsolete? I only see the QTextEdit and I do not need edit functionality. I'm afraid this will slow down drawing.
wrote on 15 Mar 2022, 08:10 last edited by@Simmania said in Which Widget to use to display simple text lines?:
I only see the QTextEdit and I do not need edit functionality. I'm afraid this will slow down drawing.
An editable widget will only affect drawing while being edited. For QTextEdit you can turn off editing. As long as all your text lines fit on a normally sized screen you don't need to worry about performance much. Most likely there are some tricks to calculate line spacing and apply it to a QTextEdit. But, like others already said, QLabels in a QVBoxLayout are much easier to handle and implement.
1/5