Multiple widgets on QDockWidget
I am creating a small application for applying various filters on an image using Qt and C ++.
My question is, is it possible to add multiple widgets to a QDockWidget ? As I want to add buttons to reapply the last 5 filters on the dock.
Here is an example of what I want to achieve.
+3
source to share
1 answer
You can add several QWidget
to any QWidget
. It sounds like you probably want to do something like this:
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);
+3
source to share