2009-10-04

Create a Dialog with Scrollbar


ListDialog::ListDialog()
{
QScrollArea *scrollArea = new QScrollArea(this);
QGroupBox *groupBox = new QGroupBox(scrollArea);
QVBoxLayout *vbox = new QVBoxLayout;

for (int i=0; i< 20; i++)
{
vbox->addWidget(new QRadioButton("item xxx"));
}

groupBox->setLayout(vbox);
scrollArea->setWidget(groupBox);

QHBoxLayout* layout = new QHBoxLayout();
layout->addWidget(scrollArea);
setLayout(layout);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}

1 comment: