QScrollArea - How To Add More Than One Widget Inside QScrollArea?
Hello There...
I Was Working Around With QScrollArea And I Tried To Add Two Widgets To It,But Each Time Only The Second One Appear.
Can I Have A Basic Example On How To Add Two Widgets To This Scroll Area?
Thanks In Advance...
Re: QScrollArea - How To Add More Than One Widget Inside QScrollArea?
When you call QScrollArea::setWidget(), it replaces the first widget with the second one. That's why it has the prefix "set" and not "add".
Two possible routes to a solution:
1 - Add a QLayout-based layout to the scroll area, and then add your multiple widgets to the layout
2 - Derive a new class from QWidget, add a layout to that, and add your widgets to that layout. Then add the derived widget to the scroll area.
The second method is the one I would choose. It is in essence exactly the same way you would create a new dialog class, except that in this case the bsae class is QWidget, not QDialog. Once you create that new widget class, you can use Qt designer to create its UI.