You just need to give your HelloWidget size and place.
Add this line to your code.
hello->setGeometry(QRect(110, 80, 120, 80));
Or, if you want to fill the scroll pane with widgets:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QScrollArea *const scroll(new QScrollArea); QHBoxLayout *const layout(new QHBoxLayout(scroll)); HelloWidget *const hello(new HelloWidget); hello->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); layout->addWidget(hello); setCentralWidget( scroll ); }
source share