I have a mainwindow of size 480 x 350. The central widget of the main window is a scroll area of dimension 190 x 220. The code for this is as below -

Qt Code:
  1. scrollArea = new QScrollArea(centralWidget);
  2. scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
  3. scrollArea->setGeometry(QRect(210, 20, 191, 221));
  4. scrollArea->setWidgetResizable(true);
  5. scrollAreaWidgetContents = new QWidget();
  6.  
  7. scrollAreaWidgetContents->setObjectName(
  8. QString::fromUtf8("scrollAreaWidgetContents"));
  9. scrollAreaWidgetContents->setGeometry(QRect(0, 0, 187, 217));
  10. scrollArea->setWidget(scrollAreaWidgetContents);
  11. MainWindow->setCentralWidget(centralWidget);
To copy to clipboard, switch view to plain text mode 

I have a QLabel which is a child of the scrollarea. The code for this is as shown -

Qt Code:
  1. QLabel* tmp = new QLabel(scrollAreaWidgetContents);
  2. tmp->setText("Custom Label");
  3. tmp->setGeometry(QRect( 300,300,60,60));
  4.  
  5. scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
  6. scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
To copy to clipboard, switch view to plain text mode 

So in the application, the scrollarea must show the scroll bars & user must be able to scroll to the qlabel , which will not be in the displayable area.

But when I run it, the scrollarea does not show the scrollbars & hence its not scrollable. How do i solve this issue? Am I doing something wrong here ?