[Qt-interest] How do I get QScrollArea to let its widget expand?
kent williams
nkwmailinglists at gmail.com
Thu Feb 24 16:53:55 CET 2011
Every time I have to do this, I have to try a bunch of different
permutations to get it to work, and THEN what I end up doing doesn't
WORK in the next context in which I try to do the SAME THING, so now
I'm asking how do I get this to work properly?
QScrollArea *scrollArea = new QScrollArea(parent);
QWidget *widgetForScrolling = new QWidget(scrollArea);
QVBoxLayout *layout = new QVBoxLayout(widgetForScrolling);
widgetForScrolling->setLayout(layout);
while( /* more widgets to add */ )
{
// make a widget
QWidget *someWidget = // whatever kind of widget...
layout->AddWidget(*someWidget);
}
The result? widgetForScrolling stays at its minimum size, no
scrollbars appear, and all the widgets inside widgetForScrolling pile
up on top of each other.
What is the thing missing from all the documentation that makes this
work right? And by "work right" I mean
1. Make a scroll area
2. Make a widget with QVBoxLayout
3. Add a bunch of other Qt UI things to it.
4. Once they're all added, if they don't fit in the scroll area, put
scrollbars on it.
More information about the Qt-interest-old
mailing list