Unsolved When the main window remains at the top, the child Windows are occluded - MacOS
-
Usually, the tools window is always at the top of the main window, even if it loses focus.However.
On MacOS, when the main window sets the window flag |Qt::WindowStaysOnTopHint, the Tool window is below it.
On a Windows system, the Tool window is at the top of the main window as expected.
Is there a way to keep the main window at the top while the Tool window is above it?
This is my test code
#include <QtGui> #include <QtWidgets> int main(int argc, char * argv[]) { QApplication app(argc, argv); QDialog* mw = new QDialog(0, Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); mw->setWindowTitle(QLatin1String("Main")); mw->resize(400, 300); mw->move(100, 100); QWidget* d = new QWidget(mw, Qt::Tool); d->setWindowTitle(QLatin1String("Tool")); d->resize(200, 100); d->show(); mw->exec(); return app.exec(); }
#include <QtGui> #include <QtWidgets> int main(int argc, char * argv[]) { QApplication app(argc, argv); QWidget* mw = new QWidget(0, Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); mw->setWindowTitle(QLatin1String("Main")); mw->resize(400, 300); mw->move(100, 100); mw->show(); QWidget* d = new QWidget(mw, Qt::Tool); d->setWindowTitle(QLatin1String("Tool")); d->resize(200, 100); d->show(); return app.exec(); }
#include <QtGui> #include <QtWidgets> int main(int argc, char * argv[]) { QApplication app(argc, argv); QWidget* mw = new QWidget(0, Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); mw->setWindowTitle(QLatin1String("Main")); mw->resize(400, 300); mw->move(100, 100); mw->show(); QWidget* d = new QWidget(mw, Qt::Tool, Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); d->setWindowTitle(QLatin1String("Tool")); d->resize(200, 100); d->show(); return app.exec(); }
-
Hi
Im not sure the Tool type will stay on top of Dialog with Qt::WindowStaysOnTopHint.
Did you try to raise() it ? -
@mrjj This doesn't seem to work. I tried setting Qt::WindowStaysOnTopHint flag on the Tool window, but it didn't help either.
-
@myxingkong
Hmm, i dont have any macOS to test on.
I suspect its due to QDialog as the mainwindow but im not 100% sure. -
HI,
What version of Qt ?
On what version of macOS ? -
@SGaist Macos version 10.13.4,Qt5.9.6 and Qt5.12.1
-
It's a bug in the Cocoa backend.
You should take a look at the bug report system to see if there's anything related. If not, please consider opening a new report providing a complete buildable project reproducing the behaviour.