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