QScrollArea *scrollArea = new QScrollArea(parent); scrollArea->setWidgetResizable(true); QWidget *scrollWidget = new QWidget(scrollArea); scrollArea->setWidget(scrollWidget); scrollWidget->setLayout(new QVBoxLayout()); // Add widgets to scrollWidget scrollArea->verticalScrollBar()->setValue(0);In this example, a QScrollArea is created with a resizable widget that can be scrolled vertically. A QWidget is added as the scrollable widget and a QVBoxLayout is set as its layout. Widgets can then be added to the layout, and finally, the verticalScrollBar is set to the top position. This example uses the Qt package library.