Discussion:
Qt/Mac : what about a (the) Window menu?
(too old to reply)
René J.V. Bertin
2018-03-06 20:31:23 UTC
Permalink
Raw Message
Hi,

I've wondered before and the question came up in a discussion: why do Qt applications not show the window menu that native applications usually have? Design decision or is there a technical reason?

Thanks,
R.
Nikos Chantziaras
2018-03-06 21:47:09 UTC
Permalink
Raw Message
Post by René J.V. Bertin
I've wondered before and the question came up in a discussion: why do Qt applications not show the window menu that native applications usually have? Design decision or is there a technical reason?
Shows up fine here. Unless I'm misunderstanding something.
René J. V. Bertin
2018-03-06 23:52:54 UTC
Permalink
Raw Message
Post by Nikos Chantziaras
Shows up fine here. Unless I'm misunderstanding something.
Indeed, the Assistant and QtCreator have the menu. But take a random 3rd party
Qt application (say, QupZilla, or Otter Browser) or just about any KF5
application and it will likely not be so lucky.

Qt Assistant rolls its own Window menu (and I guess so does Creator).

So let me rephrase: why do only some Qt applications show that menu?

R.
Hamish Moffatt
2018-03-07 00:05:21 UTC
Permalink
Raw Message
Post by René J. V. Bertin
Post by Nikos Chantziaras
Shows up fine here. Unless I'm misunderstanding something.
Indeed, the Assistant and QtCreator have the menu. But take a random 3rd party
Qt application (say, QupZilla, or Otter Browser) or just about any KF5
application and it will likely not be so lucky.
Qt Assistant rolls its own Window menu (and I guess so does Creator).
So let me rephrase: why do only some Qt applications show that menu?
It looks like the standard Windows menu to me in Assistant (Qt 5.8)? We
get the standard menu in our application too, which is exactly what we want.


Hamish
Nikos Chantziaras
2018-03-07 01:53:03 UTC
Permalink
Raw Message
Post by René J. V. Bertin
Post by Nikos Chantziaras
Shows up fine here. Unless I'm misunderstanding something.
Indeed, the Assistant and QtCreator have the menu. But take a random 3rd party
Qt application (say, QupZilla, or Otter Browser) or just about any KF5
application and it will likely not be so lucky.
Qt Assistant rolls its own Window menu (and I guess so does Creator).
So let me rephrase: why do only some Qt applications show that menu?
It might be a QML issue. In Widgets, when using QMainWindow, you get an
application menu by default. In QML with Qt Quick Controls, it seems
this got only added in Qt 5.10:

https://doc.qt.io/qt-5.10/qml-qtquick-controls2-menubar.html

In other words, don't use QML for desktop applications if you can avoid
it :-/
Mitch Curtis
2018-03-07 06:24:04 UTC
Permalink
Raw Message
-----Original Message-----
On Behalf Of Nikos Chantziaras
Sent: Wednesday, 7 March 2018 2:53 AM
Subject: Re: [Interest] Qt/Mac : what about a (the) Window menu?
Post by René J. V. Bertin
Post by Nikos Chantziaras
Shows up fine here. Unless I'm misunderstanding something.
Indeed, the Assistant and QtCreator have the menu. But take a random
3rd party Qt application (say, QupZilla, or Otter Browser) or just
about any KF5 application and it will likely not be so lucky.
Qt Assistant rolls its own Window menu (and I guess so does Creator).
So let me rephrase: why do only some Qt applications show that menu?
It might be a QML issue. In Widgets, when using QMainWindow, you get an
application menu by default. In QML with Qt Quick Controls, it seems this got
https://doc.qt.io/qt-5.10/qml-qtquick-controls2-menubar.html
That's a non-native menu bar; this one is native and has been around since 5.8:

https://doc.qt.io/qt-5.10/qml-qt-labs-platform-menubar.html

Coincidentally, I'm happily using it in a Qt Quick desktop application:

http://blog.qt.io/blog/2018/03/06/slate-basic-pixel-art-editor-built-qt-quick/
In other words, don't use QML for desktop applications if you can avoid it :-/
Nitpick: Qt Quick*
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
René J. V. Bertin
2018-03-07 09:05:19 UTC
Permalink
Raw Message
Post by Nikos Chantziaras
In other words, don't use QML for desktop applications if you can avoid
it :-/
I wouldn't...
Post by Nikos Chantziaras
It looks like the standard Windows menu to me in Assistant (Qt 5.8)? We
get the standard menu in our application too, which is exactly what we want.
I suppose that's not an open source application?

In the Assistant that menu is created explicitly and populated with the Minimise
and Zoom actions. The menu itself is held by a local variable and thus isn't
referenced anywhere else. AFAICT that means it will only ever contain those 2
items, which seems to be confirmed in practice.

There is a design difference that's relevant here: Qt applications tend to use
tabs or subwindows in a single (or handful) of main windows; native Mac
applications tend to use more individual windows, and that's what the automatic
Window menu we're used to works with (see also NSApplication(NSWindowsMenu) ).

I don't see any evidence (in Qt 5.9 and earlier) of an explicit deactivation of
the window menu (there's a call to exclude specific NSWindows from it), but I
also don't see any evidence that a Window menu is created and declared (via
NSApplication:setWindowsMenu). I added a debug probe at an appropriate location
in the Cocoa QPA and indeed, `[NSApp windowsMenu]` returns NULL in random
applications.

R.
René J.V. Bertin
2018-03-07 17:52:03 UTC
Permalink
Raw Message
Here's a small PoC patch to the Cocoa QPA (5.9) which adds a Windows (sic) menu:

https://github.com/RJVB/osx-integration/blob/qt590/src/qcocoa-qpa/patches/33-patch-add-windows-submenu.diff

I don't think it will be trivial to create the standard Window menu that sits just left of the Help menu in the menubar (where is that menu created??). Instead the patch just adds a submenu to the Application menu and makes this the application's window menu, activating it when a NSWindow instance is allocated. The system then takes care of the rest.

Evidently this isn't in accordance with HIG and tradition, but IMHO the location I use isn't otherwise really out of place, just above the application visibility controls. :)


R.

Loading...