Reputation: 699
I have a bunch of buttons in Qt with a fixed size. Now I want to create a layout in which they are shown in a grid. I want the grid to be scrollable and when I resize my mainwindow, the grid should fit as much buttons in the layout as possible. The number of rows and columns are therefore not fixed.
I tried creating this with the hbox, vbox and gridlayout but they either put all the buttons below each other, or side by side. Also it resizes my mainwindow to an enormous size to fit all the buttons in.
Any Ideas?
Upvotes: 1
Views: 914
Reputation: 40492
Put QScrollArea inside your QMainWindow. Apply QGridLayout to QScrollArea's inside widget and put the buttons inside it.
Upvotes: 3