Mac, 4.8.5: QAction in main menu not obeying AboutRole menu role [Solved]
-
Hi,
I'm not sure I am following you properly so:
It's working properly with Qt 4.8.4 but not 4.8.5, is that right ?
-
I have rewritten my post. It was late.
As I recall, yes, but it's been a while. At least it worked in 5.x.
-
Just tried with a little dummy app but it seems to be working. Do you have a minimal example that I could try ?
-
Just tried the same; works in a new project. I'll try to boil my project down to a minimal main window example.
-
Found the problem. As per http://qt-project.org/doc/qt-4.8/qmenubar.html#qmenubar-on-mac-os-x , menu item texts containing the string "about*" automatically gets assigned the menu role, and moved to the "appropriate" place. The problem is, my application is a browser-like application with dynamically loaded browser bookmark and history menus. Guess what? Some of the items were from "about.com", which explains that when I triggered the "About..." menu item, the page from about.com gets loaded. Sort of explains everything.
But - both QAction::setMenuRole(QAction::NoRole) and QAction::setMenuRole(QAction:: TextHeuristicRole) on the dynamic items are being ignored. They are still triggered by the "About..." menu item.
I'm pretty sure this was ok in Qt4.8.4.Am I overseeing something here? I just need ONE Qt version that works properly on the Mac, then I would be happy. If I'm not overseeing something, then I'm out options, and will start porting my application to pure c or assembly language. That would probably be less frustrating.
-
Can you post a minimal QAction setup that shows this behavior ?
-
Nope, thankfully :-D
Created a minimal example, turns his the menu role HAS to be QAction::NoRole, QAction::TextHeuristicRole won't cut it. Once I changed this consistently in my application, it worked.
Thanks ;-)
-
Great ! :)
Thanks for sharing the solution.
You could add a doc note on QAction explaining this, that might help others :)
-
Done for 4.8 :-)
-
Nice, thank you !