QWidget created in an aux method does not show/draw
-
If I create the widget in the body of its parent widget class it is all good:
@new NodeWidget(rootItem, this); // this works@
But when I use the aux method the widget is created, but never drawn.
@rootItem->createWidget(this); // internally rootItem does the same thing as above@
The method itself:
@void createWidget(QWidget * target) {
if (!_ui) _ui = new NodeWidget(this, target);
...
}@The way I see it, both approaches do the same thing, but the first one works while the second one does not. The NodeWidget constructor runs, but the widget does not appear in the parent widget and the paintEvent is never called. Any ideas why?
EDIT: This is certainly odd, I noticed that the following line:
@new QPushButton(this);@
works when called in the constructor of the parent widget, but not when called from the mousePress event. What is the difference?
-
Hi,
What do you mean by "works"? How do you store the new widget in both cases? Do you place the new widget in the parent's layout? Do you call QWidget::show()?