View Full Version : Dynamic grid layout

12th June 2006, 10:17
I'm looking for the best way to lay out a dynamic number of controls in a grid. I need to be able to add or remove controls from the layout and change the number of controls per row (in effect change the number of cols and rows). I've tried using a QGrid-control but it does not support changing the number of cols/rows (and has some other issues) and I've looked at the QGridLayout, however it does not support decreasing the number of cols/rows.

My current solution is to create a new QGrid with the right dimensions, move all controls from the old QGrid (which is then deleted) and add the new QGrid to the dialog layout. However this is not a particulary good solution and I was wondering if someone had a better.

12th June 2006, 16:19
I'd suggest to create a custom layout. You may have a look at the source of QGridLayout to understand how it works and then customize it to fit your needs... The border layout example may be helpful as well...