Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] QGridLayout: widget takes too much space
I've met a problem that QToolBar takes way too much space on my layout so other widgets are moved too far from the place where they should be. I've tried SetMaximumSize(), SetFixedSize() and so on and none works. Yes, I've read post describing why QGridLayout has no "MaximumSize" property, although I've read a lot of other posts and nothing helps... Could you give me an advice please?
I can't believe nobody has something to say :(
If you need more information just say it...
gmaro last edited by
I would like to help but I don't see clearly your problem. Can you share the code corresponding to the used widgets and layout? On other hand - how you set the size policies?
lgeyer last edited by
Honestly, I don't quite get your example, but I'll try it anyway: you have a QGridLayout, consisting of several widgets left and right of a QToolBar, which keeps growing larger then it has to be.
Well, this is due to the fact that the default size policy for QToolBar is Preferred, which basically means that QToolBar might expand if there is additional space, although it doesn't benefit from doing so.
Just set the size policy to Maximum, which prevents the QToolBar from exceeding its absolutely minimum dimensions.
Solved by now. Thanks all.
What didnt help: setting QToolBar's sizePolicy
What helped: setting QToolBar's to Minimum,Maximum and adding few Expanding QSpacerItem