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.