Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt - how to get top level parent from the given widget?

Tags:

qt

pyqt

How can given widget access it's oldest parent, which is top level widget.

I need to .showMinimized() it.

Now I am using

self.parent().parent().parent().showMinimized()

But it seem not to be the best way for this.
If it it moved, I need to change number of parent manually.

Is there a way to access top level widget?

like image 895
Qiao Avatar asked May 28 '11 03:05

Qiao


1 Answers

If you're just trying to get to the window widget, there's QWidget.window().

self.window().showMinimized()
like image 172
John Flatness Avatar answered Dec 15 '22 18:12

John Flatness