PyQt4: How can I switch the behavior of "Stay On Top"?

I want to create an application where the user decides that the main window will always remain on top of other applications.

In PyQt4, it’s easy to create a window that always stays on top. This is described here: PyQt: Always on top

I want to have a widget (menu item, checkbox, etc.) that will turn this behavior on or off. So far, I have not found a way to reset the original behavior.

Thank you

UPDATE After the İsmail 'cartman' Dönmez suggestion, I searched a little more and I found an implementation of the WindowFlags example in PyQt4.

Here you can find

+4
source share
4 answers

This should disable it:

window.setWindowFlags(window.windowFlags() & ~QtCore.Qt.WindowStaysOnTopHint)

This should include it:

window.setWindowFlags(window.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
+13
source

Qt::WindowStaysOnTopHint, . Windows.

+4
. window.show() . . .

:

window.setWindowFlags(window.windowFlags() ~ QtCore.Qt.WindowStaysOnTopHint)

:

window.setWindowFlags(window.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)

:

window.setWindowFlags(window.windowFlags() ^ QtCore.Qt.WindowStaysOnTopHint)

+4

, - PyQt 5.7 Devuan, WindowStaysOnTopHint QDialog , , , () . , .

+1

Source: https://habr.com/ru/post/1788970/


All Articles