Qiao
Qiao

Reputation: 17049

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

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?

Upvotes: 15

Views: 16036

Answers (1)

John Flatness
John Flatness

Reputation: 33749

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

self.window().showMinimized()

Upvotes: 26

Related Questions