How to get the Top(base) parentWidget in QT?

Viewed 18135

I am creating a software that must be accessible by parent to childrenWidget (or children of the children of the children....) and from the children to the parentWidget (or the parent of the parent of the parent ...).

For example :

QWidget_Principal --> WidgetApplications --> WidgetMenuBar --> PushButtonFullScreen.

The problem is that the way I can do this, is doing

this->parentWidget()->parentWidget()->parentWidget()->showFullScreen();

This there a simple way to do that ?

Thanks in Advance And sorry for my very bad english.

Luis Da Costa

4 Answers

Really simple python answer, call this within any child widget class of course:

top_widget = self
while top_widget.parentWidget(): top_widget = top_widget.parentWidget()
Related