[Interest] Modeless dialog issue on Mac

Tor Arne Vestbø Tor.arne.Vestbo at qt.io
Tue Nov 14 19:10:30 CET 2023


A non-modal Dialog (NSPanel) isn’t inherently at a higher window level than a normal window on macOS:

<https://developer.apple.com/documentation/appkit/nswindowlevel?language=objc>
[developer-og.jpg]
NSWindowLevel | Apple Developer Documentation<https://developer.apple.com/documentation/appkit/nswindowlevel?language=objc>
developer.apple.com<https://developer.apple.com/documentation/appkit/nswindowlevel?language=objc>

We could potentially work around it by using a non-standard window level, but it might have unforeseen consequences.

I recommend using the Qt::WindowStaysOnTopHint as a workaround.

Tor Arne


On 14 Nov 2023, at 18:55, Oliver Knoll <till.oliver.knoll at gmail.com> wrote:



Am 14.11.2023 um 16:29 schrieb Calogero Mauceri <mauceri at actgate.com>:


Here "this" is a pointer to the parent dialog. I've tried with QMainWindow too as a parent, but unfortunately the problem is still there, not sure if that's another bug.
The only way I found for having the modeless dialog on top of its parent is to create it with Qt::Tool flag.

You don‘t need to create a „tool window“: any QWidget (QWindow?) based window should do.

From the top of my head there should exist an „always on top“ window flag. Pass this to the constructor of your QDialog, refer to the Qt docs wrt „window flags“ (or similar).

I definitively managed to keep a QMainWindow „always on top“ with this approach (Win/Mac/Linux), but I expect this to work with QDialogs, too.

Best,
 Oliver
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231114/2b5f8c01/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: developer-og.jpg
Type: image/jpeg
Size: 39580 bytes
Desc: developer-og.jpg
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20231114/2b5f8c01/attachment-0001.jpg>


More information about the Interest mailing list