Redrawing Widget after replacing containing Widget
Solved
General and Desktop
-
I have a Widget (Parent) that has a layout in which another Widget (Child) is used. At some point, I need to replace the Child Widget by a new one and the Parent Widget needs to be redrawn. Naively, I wrote the following code as part of the Parent Widget:
delete Child; Child = new ChildWidget(); repaint();
The problem is that the new Child is not drawn and instead the whole Child Widget area is no longer part of the layout. How can I solve this?
-
Hi,
You're creating a new widget in the "void". You should put it in place of the old one. For example, if
Child
was in a layout, put the new object there.If you must replace it like that, why not have a "reset" function in ChildWidget ? That might be less aggressive.