Please help with Qt::WindowStaysOnTopHint
-
(Linux Debian) I've made a function to make the app window to be always on the top. But I can't make the function which cancel that mode back (to normal mode). Please help.
static Qt::WindowFlags flags_mem;
void Tblf::on_mi_over_all_windows_triggered()
{
flags_mem = windowFlags();
setWindowFlag(Qt::WindowStaysOnTopHint, true);
show();
activateWindow();
}
//---------------------
void Tblf::on_mi_notover_all_windows_triggered()
{
setWindowFlags(flags_mem);
show();
activateWindow();
//raise();
} -
-
@jsulm said in Please help with Qt::WindowStaysOnTopHint:
Did you make sure that on_mi_notover_all_windows_triggered() is actually called?
Also, there is no need to store all the flags in a member variable, setWindowFlag(Qt::WindowStaysOnTopHint, false) should do.I did as you said also. The funcion on_mi_notover_all_windows_triggered() is called I checked it in the debugger. Please note that the cancelling "always on top mode" is not working only after you click "always on top" mode" first (on_mi_over_all_windows_triggered() I mean). Please check it.
void Tblf::on_mi_over_all_windows_triggered()
{
setWindowFlag(Qt::WindowStaysOnTopHint, true);
show();
activateWindow();
}
//---------------------
void Tblf::on_mi_notover_all_windows_triggered()
{
setWindowFlag(Qt::WindowStaysOnTopHint, false);
show();
activateWindow();
} -
Hi,
You should test the WindowFlags example and see how it behaves on your system.
-
@SGaist said in Please help with Qt::WindowStaysOnTopHint:
You should test the WindowFlags example and see how it behaves on your system.
I have tested it - you can check "Window stays on top" and make the window "always on top" - but you cannot cancel the mode. I mean after unchecking "Window stays on top" the the new created window will be on top anyway (even after you choose another option). It is a poor example (for people who want to turn on/off the option "stay on top"). The QTcreator developers who put this example should know about it.
-
@qAlexKo said in Please help with Qt::WindowStaysOnTopHint:
The QTcreator developers who put this example should know about it.
Well, then you should let them know - file a bug. They can't test on each and every platform with all existing desktop environments and window managers. File a bug on Qt bug tracker and describe your setup including used window manager/desktop environment.
-
@qAlexKo
This has been reported as a problem under X11 a couple of times that I can see in posts, e.g. https://forum.qt.io/topic/77475/remove-qt-windowstaysontophint-flag-in-linux and https://stackoverflow.com/questions/53141178/pyqt5-cant-delete-flag-windowstaysontophint-under-ubuntu-18-04.Unfortunately I do not see a solution or workaround, nor whether this has been raised as a Qt bug or not.
There is also https://www.qtcentre.org/threads/5730-Changing-AlwaysOnTop-window-flag, but I'm not sure if it applies to X11. (Possibly similar: https://forum.qt.io/topic/31197/unset-qt-windowstaysontophint-flag-problem. Looks like this has been behaviour at least since 2013!) Someone there claimed to get it working perhaps with a
hide()
/show()
, which you might try? -
@JonB said in Please help with Qt::WindowStaysOnTopHint:
You may not like to hear this, but https://bugreports.qt.io/browse/QTBUG-69515 seems to address this, but shows:
Fix Version/s:
6.2.0 Beta3, 6.3.0 Alpha, 5.15.6So you may have to wait for/get one of these....
The Qt 6.2.0 Release Candidate is available to everyone for testing right now. Or, you can wait till Qt 6.2 is released (it is scheduled for 30 September 2021). Or, if you are a commercial customer, you can download Qt 5.15.6 right now.
-
@JonB said in Please help with Qt::WindowStaysOnTopHint:
This has been reported as a problem under X11 a couple of times that I can see in posts, e.g. https://forum.qt.io/topic/77475/remove-qt-perhaps with a
<skipped>Yes, it is an issue for many people. BTW - if you go to form system menu (upper left corner) you go to Properties and you can remove that stubborn flag manually.
<skipped>
hide()/show(), which you might try?I tried without success.
Anyway thanks.