Reputation: 2726
Newbie here. I have a dock widget, and in it I created three groupbox, and using VBoxLayout for these three groupboxes. But the problem is when the window is maximized, the three groupboxes fill the whole dock widget and there a lots of large spacing inside of the items in the groupboxes. How can I keep the size of groupbox fixed and also as in the whole dock widget panel, keep them all aligned on the top?
What's the trick? Thanks
Upvotes: 3
Views: 2907
Reputation: 1631
You have to add a QSpcerItem
but not directly :
Normally, you don't need to use this class directly. Qt's built-in layout managers provide the following functions for manipulating empty space in layouts: ...
from Qt documentation : http://doc.qt.digia.com/qt/qspaceritem.html#details
you have to use :
myLayout->addStretch()
Upvotes: 2
Reputation:
Use a QSpacerItem
. For a vertical spacer use:
QSpacerItem ( width, height, QSizePolicy::Minimum, QtGui.QSizePolicy::Expanding )
And for an horizontal:
QSpacerItem ( width, height, QtGui.QSizePolicy::Expanding, QSizePolicy::Minimum )
Upvotes: 0