mainLayout = new QVBoxLayout(this); area = new QScrollArea(this); fLayout = new QVBoxLayout(area); fLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); QPushButton *b; for ( int i = 0; i < 20; i++ ) { b = new QPushButton(QString("%1").arg(i)); b->setFixedSize(50, 50); fLayout->addWidget(b); } mainLayout->addWidget(area); mainLayout->addWidget(new QPushButton("b")); setLayout(mainLayout);
QVBoxLayout *mainLayout = new QVBoxLayout(this); QScrollArea *area = new QScrollArea(this); QVBoxLayout *scrollLayout = new QVBoxLayout(area); scrollLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); QPushButton *b; for ( int i = 0; i < 20; i++ ) { b = new QPushButton(QString("%1").arg(i), area); b->setFixedSize(50, 50); scrollLayout->addWidget(b); } mainLayout->addLayout(scrollLayout); mainLayout->addWidget(new QPushButton("b"));
scrollArea = new QScrollArea(this); scrollingWdg = new QWidget(scrollArea); layout = new QVBoxLayout(scrollingWdg); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setGeometry(5, 5, 290, this->height()); setFixedWidth(300); .... scrollingWdg->setLayout(layout); scrollArea->setWidget(scrollingWdg);