Reputation: 823
Is it possible to add dynamically new child widget to the parent?
I have the following code:
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
Vector m_otherWidgets
contains a list of child widgets. The problem is that it display only this child widgets, that were created during constructor time.
Upvotes: 1
Views: 105
Reputation: 2033
Without more information I can only guess, but you probably forgot to call show()
/setVisible(true)
. Widgets added after the parent is shown are not always displayed.
Upvotes: 2