PDA

View Full Version : QWidget + QScrollArea = confused



papillon
16th November 2011, 10:57
Hi, I have developed an application with a main QWidget, which contains other controls. I have declared it like this:

myWindow = new QWidget(0, "mainWindow");
myWindow->show();
myWindow->setWindowTitle("Window Title");

The widget is resizable, and how'd like to have scrollbars appear when it's size is reduced. I tried to use QScrollArea without success (also Googled but couldn't find a simple example).

Could somebody please give me a hint? Thanks

Spitfire
16th November 2011, 14:19
For example:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QScrollArea* scroll = new QScrollArea();
QWidget* w = new QWidget();
w->setWindowTitle("test");
w->setMinimumSize(300,200);
scroll->setWidget(w);
this->setCentralWidget(scroll);
}When MainWindow is resized below 300x200 scroll bars will appear.

papillon
16th November 2011, 14:38
Thank you very much. Appreciated.