PDA

View Full Version : Automatic reestructuring of elements of a grid layout



quimnuss
13th January 2016, 10:05
I have a QGroupBox which contains many QCheckboxes. I use a QVBoxLayout to place them, but I would like the layout to place the QCheckboxes in a grid fashion, adapting the number of columns to the horizontal space available.


Do I have to code the behaviour myself or is there a layout that does that automatically?

Thanks!

anda_skoa
13th January 2016, 11:09
Sounds like a use case for a flow layout http://doc.qt.io/qt-5/qtwidgets-layouts-flowlayout-example.html

Cheers,
_

quimnuss
13th January 2016, 11:32
indeed!

Correct me if I'm wrong, FlowLayout is not part of Qt, right?

Added after 15 minutes:

And is there a way to set this layout on QtDesigner?

Nevermind: http://stackoverflow.com/questions/5659875/custom-layout-in-qt-designer