I am adding several push buttons in QVBoxLayout
and adding this layout in QDockWidget
, now I want to add some scroll bar in the same Layout(DockWidget) to change(Increase/Decrease) data shown in separate EditBox.
The problem is the Scroll bar is added above the buttons,I want all the buttons at right side and the scroll bar in the left side.
The reason why I am using QDockWidget
is I am also adding animation effect using QPropertyAnimation
class.
Below is the sample code
QDockWidget dock(QLatin1String("Last filters"));
QWidget* multiWidget = new QWidget();
QVBoxLayout* layout = new QVBoxLayout();
QPushButton* filter1 = new QPushButton(QLatin1String("Filter number 1"));
QPushButton* filter2 = new QPushButton(QLatin1String("Filter number 2"));
QPushButton* filter3 = new QPushButton(QLatin1String("Filter number 3"));
QPushButton* filter4 = new QPushButton(QLatin1String("Filter number 4"));
QPushButton* filter5 = new QPushButton(QLatin1String("Filter number 5"));
QLabel* label = new QLabel(QLatin1String("QPushButtons"));
layout->addWidget(filter1);
layout->addWidget(filter2);
layout->addWidget(filter3);
layout->addWidget(filter4);
layout->addWidget(filter5);
layout->addWidget(label);
multiWidget->setLayout(layout);
dock.setWidget(multiWidget);
** For animation
QPropertyAnimation *animation = new QPropertyAnimation(dockMenu, "geometry");
animation->setDuration(250);
QRect startRect(-100,20,100,80);
QRect endRect(20,20,100,80);
dockMenu->show();
animation->setStartValue(startRect);
animation->setEndValue(endRect);
animation->start();
For this application this answer at Multiple widgets on a QDockWidget helped me but now to add the scrollbar I am not able to relocate/move the widgets