How can I automatically adjust the size of a label to a frame?
772
I try to automatically adjust the size of one labelto the main window, I am using lay out horizontallyit but it changes the dimension both in width and height, I only want it to auto adjust in height and not in width
It is the first time that I respond with images. I put the example made in QDesigner. If it's with code, you don't have much problem either:
The idea is to have the QLabelbetween two horizontalSpacerand three elements inside a QHBoxLayout, and in turn adjust it to the widget with another layout.
For the to QLabel have a defined width, you have to adjust the size to that width ( minimumSizey maximumSize)
And if you want a fixed distance to the top left corner, you can adjust it on horizontalSpacerthe left one.
It is the first time that I respond with images. I put the example made in QDesigner. If it's with code, you don't have much problem either:
The idea is to have the
QLabel
between twohorizontalSpacer
and three elements inside aQHBoxLayout
, and in turn adjust it to the widget with another layout.For the to
QLabel
have a defined width, you have to adjust the size to that width (minimumSize
ymaximumSize
)And if you want a fixed distance to the top left corner, you can adjust it on
horizontalSpacer
the left one.