ComServant
2nd April 2012, 02:04
I have a QScrollArea, and I add widgets to the scroll area as my program runs. I want the order of the widgets to be in the order I add them (first added should be at the top, second added should be next, and so on).
I want all the widgets pushed to the top of the QScrollArea, so I call layout->stretch().
The problem is, how can I insert a new widget at the second to last position of the QScrollArea, so it's after my previous widgets, but before the stretch?
Alternatively, how can I delete the stretch, so I can add the widget and then re-add the stretch?
I've tried messing with this numerous times in the past, and I always end up using some hacky way to get it working. What's the best way to do this?
I'm aware of insertWidget, but I can't figure out how to get the index of the stretch so I can insert before it.
Any hints?
I want all the widgets pushed to the top of the QScrollArea, so I call layout->stretch().
The problem is, how can I insert a new widget at the second to last position of the QScrollArea, so it's after my previous widgets, but before the stretch?
Alternatively, how can I delete the stretch, so I can add the widget and then re-add the stretch?
I've tried messing with this numerous times in the past, and I always end up using some hacky way to get it working. What's the best way to do this?
I'm aware of insertWidget, but I can't figure out how to get the index of the stretch so I can insert before it.
Any hints?