Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QLabel won't expand depending on text content
bam500 last edited by
I am experiencing an issue with a QLabel in a QDialog. I'd like my QLabel to expand depending on the text content.
This QLabel is in a QHorizontalLayout, itself in a QVerticalLayout.
Here's how it's designed :
I have changed the QLabel's sizePolicy to Expanding.
I have set the layoutSizeConstraint of all the labels to SetMaximumSize.
But here's how it's displayed :
It still won't expand.
Anyone would have an idea of what I don't see here ?
m.sue last edited by m.sue
you will have to use FIXED (and not prescribe an actual size) to set the label size according to its contents. Expanding means, every widget with policy EXPANDING gets as much space as allowed by the other widget's policies, maybe more or less than its contents size. If there are two or more widgets with EXPANDING they share the "allowed" space.