QDockWidget 上的多个小部件
我正在制作一个小应用程序,用于使用 Qt 和 C++ 在图像上应用各种滤镜.
I'm making a little app for applying various filters on an image using Qt and C++.
我的问题是,是否可以在 QDockWidget 上添加多个 widgets ?因为我想添加按钮以重新应用扩展坞上的最后 5 个过滤器.
My question is, is it possible to add multiple widgets on a QDockWidget ? As i want to add buttons for re-applying the last 5 filters on the dock.
这是我想要实现的示例.
Here is an example of what i want to achieve.
推荐答案
可以将多个QWidget
添加到任意QWidget
中.看起来你可能想做这样的事情:
It is possible add to multiple QWidget
s into any QWidget
.
It looks 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);
相关文章