I’m having trouble trying to get the QGridLayout to behave like I need. Ideally I would like to just add a widget and have it stack based on a pre-determined number of columns so that when it reaches, say the 4th column, it then starts adding the widget to the next row and so on. I’ve been on stackOverflow and expertsExchange an haven’t found anyone getting this functionality yet. Right now when I add a widget it is just centered and stacks vertically. Am I missing something? Having to specify the column and row on instantiation seems unintuitive doesn’t provide the kind of dynamic behavior I need without adding a bunch of extra variables to track the currentColumn and row to add the next widget to. Can anyone shed some light?:?:
GridLayouts job is to show stuff in a grid and not change any layout behaviour dynamically.
| 0,0 | 0,1 |
| 1,0 | 1,1 |
The layout you are seeking is unfortunately not available in Qt, I think, you’ll have to implement this behaviour yourself by inherinting one of the base layout classes and calculate the desired positions etc.
Awesome, well then I will do so and post it here when I’m done
I think this is what you are after:
Flow Layout Example in C++:
http://harmattan-dev.nokia.com/docs/library/html/qt4/layouts-flowlayout.html
It stacks horizontally and switches down if space is not available. Use that as a base!
I found a PyQt version of that and put it in Maya and it seems to work so far, I might have to tweak it a little. Thanks Yasin.