QWidget * widget1 = new QWidget ; QVBoxLayout *lay = new QVBoxLayout; lay->setSpacing(10); for (int i = 0;i < 20;i++) { QPushButton *pb = new QPushButton(QString::number(i)); pb->setFixedSize(30,20); lay->addWidget(pb); } widget1->setLayout(lay); ui->scrollArea->setWidget(widget1);