hasmik
7th July 2009, 09:34
Hi,
I create editor which enables user to draw different shapes. There is a centralWidget where shapes are drawn and toolbar on the right side which contains many toolButtons. ToolButtons are laid out by QVBoxLayout. I want that toolbar could be scrollable. If I use srollArea I don't get what I want.
void MainWindow::createLayerToolBar() {
...
layerToolBar = new QToolBar(tr("Layers"));
addToolBar(Qt::RightToolBarArea, layerToolBar);
...
QScrollArea * scrollArea = new QScrollArea(this);
scrollArea->setWidget(layerToolBar);
scrollArea->setAlignment(Qt::AlignCenter);
scrollArea->viewport()->setBackgroundRole(QPalette:ark);
scrollArea->viewport()->setAutoFillBackground(true);
scrollArea->setVerticalScrollBarPolicy(Qt:crollBarAlwaysOn);
}
I know that this line is written wrong: QScrollArea * scrollArea = new QScrollArea(this).
What I should change in my code that scrollArea is appeared on the right side of the central widget and contains layerToolBar?
Is there another solution?
Thanks in advance.
I create editor which enables user to draw different shapes. There is a centralWidget where shapes are drawn and toolbar on the right side which contains many toolButtons. ToolButtons are laid out by QVBoxLayout. I want that toolbar could be scrollable. If I use srollArea I don't get what I want.
void MainWindow::createLayerToolBar() {
...
layerToolBar = new QToolBar(tr("Layers"));
addToolBar(Qt::RightToolBarArea, layerToolBar);
...
QScrollArea * scrollArea = new QScrollArea(this);
scrollArea->setWidget(layerToolBar);
scrollArea->setAlignment(Qt::AlignCenter);
scrollArea->viewport()->setBackgroundRole(QPalette:ark);
scrollArea->viewport()->setAutoFillBackground(true);
scrollArea->setVerticalScrollBarPolicy(Qt:crollBarAlwaysOn);
}
I know that this line is written wrong: QScrollArea * scrollArea = new QScrollArea(this).
What I should change in my code that scrollArea is appeared on the right side of the central widget and contains layerToolBar?
Is there another solution?
Thanks in advance.