Create a widget with a layout to which you'll be adding new lables then stick that widget into scroll area.
Something like this:
MainWindow::MainWindow()
{
container->setLayout( lay );
sa->setWidget( container );
this->setCentralWidget( sa );
lay
->addWidget
( new QLabel( "new label" );
}
MainWindow::MainWindow()
{
QVBoxLayout* lay = new QVBoxLayout(); //cache this pointer so you can easily add new labels later
QWidget* container = new QWidget();
container->setLayout( lay );
QScrollArea* sa = new QScrollArea();
sa->setWidget( container );
this->setCentralWidget( sa );
lay->addWidget( new QLabel( "new label" );
}
To copy to clipboard, switch view to plain text mode
Now when you add too many labels to fit on the screen scroll area will show scroll bars to navigate through widgets content.
Edit:
Forgot to mention that you have to set
sa->setWidgetResizable( true );
sa->setWidgetResizable( true );
To copy to clipboard, switch view to plain text mode
otherwise scroll area will not resize container widget as more contents is added.
Bookmarks