Can a widget be notified if it's parent changed?
-
Hi all!
I have several dock widgets in my project, all of which contain widgets that are subclasses of the same base class (this class is QWidget subclass). In this base class, I want to implement layout margins recalculation in case the parent widget is a dock widget and the dock area has been changed (via a connection toQDockWidget
signal). The point is my class knows nothing about a dock widget wrapper and it needs to be notified that the parent is changed when it's put inside a dock widget to create a connection.
There is an ugly way to achieve my needs by calling something likeMyBaseClass::DockParentSet
every time afterQDockWidget::setWidget
and create a connection in this function, but I would prefer to encapsulate this detail if possible.
Is there an elegant way to notify a widget if its parent has changed? -