1
是否可以向父窗口动态添加新的子窗口小部件?动态添加叠加窗口小部件
我有以下代码:
MyWidget : public QWidget
{
MyWidget() : Qwidget()
{
m_otherWidgets.push_back(new OtherWidget(this)); // this will be painted
}
void addNew()
{
m_otherWidgets.push_back(new OtherWidget(this)); // this will not be painted
}
std::vector<OtherWidget*> m_otherWidgets;
}
MyWidget bar(); // 1 other widget painted
bar.addNew(); // still only 1 other widget painted
矢量m_otherWidgets
包含子控件的列表。问题是它只显示在构造函数时间创建的子窗口小部件。
谢谢,这解决了这个问题。 – Serbin