[Qt-interest] scroll area from designer
Duane Hebert
spoo at flarn.com
Fri Nov 5 21:01:06 CET 2010
I need to use a scroll area and fill it up with some widgets at runtime.
I can put a frame on a form in designer, then at run time, build a scroll area with the frame as parent, create a group box, set the
groupbox as the widget for the scroll area and create my widgets with the group box as a parent. When I'm done, I can call
adjustSize() on the group box.
Like:
QScrollArea *Scroll = new QScrollArea(ui.frame);
QGroupBox *Box = new QGroupBox(this);
Scroll->setWidget(Box);
int yPos(0);
for(int i = 0; i < 20; ++i) {
QPushButton *pb = new QPushButton(Box);
pb->setText(QString::number(i));
pb->move(0,yPos);
yPos += 20;
}
Box->adjustSize();
Box->show();
Box->adjustSize();
Box->show();
This works, but then I have to size the scroll area to the correct size and handle resize events to do the same.
What's the correct way to do this from Designer? There's a QScrollArea that I can drop on the form, but I don't see a way to use
this.
Thanks.
--
Duane Hébert
Sofware Development
United Process Control
More information about the Qt-interest-old
mailing list