Qt5 OS X menubar empty menu-item not hidden - macos

I'm using Qt5 on OS X 10.8 and I'm creating an application with a menu bar in Qt Creator. Placing items like Quit or Preferences in the application menu works by specifying the menuRole accordingly. However, since those items need to be placed in some menu and then get moved automatically by Qt into the application menu I end up with empty menu items.
According to this the empty items should be hidden but for me they are not.
What I have is this:
File
Preferences
<Separator>
Quit
Help
About
Preferences, Quit and About are correctly moved to the application menu. Unfortunately File and About are still shown. How can I make Qt hide them?

After going back to the project about 10 months and two minor Qt versions later, the problem is now gone. I just installed Qt 5.2 on OS X 10.9 and the app's menu is as expected.

Related

SDL 2.0 on Mac - how to activate/respond to greyed-out Toggle Full Screen menu item?

Working on porting a Windows game to Mac using SDL2, and I noticed on the Mac that the menu bar for the game includes a View menu with an item Toggle Full Screen. I'm assuming SDL put it there automatically, as I didn't request it anywhere in my code. However, since the game can run in a window or full screen (and the window is resizable), I figure I should make this menu item actually work somehow.
I know practically nothing about Mac OSX coding (I just followed a tutorial to get my SDL app to build on the Mac side in XCode), and I can't find anything in the SDL documentation about how to respond to, activate, or remove this menu item (or other ones that are greyed out, like the Minimize option in the Window menu). Best I could find online is a reference to it being added in a commit to the SDL code base, but nothing in the commit message about how one is supposed to hook it up to their application code.
So, how do I activate and respond to this menu item (and any other menu items that only show up in OSX builds for that matter, like Minimize and About)? And is it something I can hook up in a cross-platform way via SDL itself, or did SDL add something that I have to deal with using platform-specific OSX code?

How to change the Mac OS X dock icon in a wxPython application

When a wx.App is launched through a script (i.e., not bundled with py2app) its icon in the dock is the standard Python rocket. Is it possible to customize that icon? It seems that in the past wx.TaskBarIcon did this (see http://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon), but now it adds an icon to the menu bar.
I had the same issue and it seems there is a lack of documentation about this. I found several piece of information in different discussion threads.
You have to use the iconType argument of the wx.TaskBarIcon constructor. there are currently three possible values:
wx.TBI_CUSTOM_STATUSITEM: will create an icon in right part of the menu bar.
wx.TBI_DEFAULT_TYPE: default parameter, similar as TBI_DOCK for wxPython 3.0.
wx.TBI_DOCK: will replace the Python rocket with the selected icon
If you reuse the example from the wx official documentation, you just need to replace this line
wx.TaskBarIcon.__init__(self)
with this line
wx.TaskBarIcon.__init__(self, iconType=wx.TBI_DOCK)
The problem with this solution is that you have to choose to put the icon either in the menu bar either in the dock. It does not seem possible to put an icon in the both place while using only one instance of wx.TaskBarIcon.
Here are my current settings:
mac os X 10.11.5
wxPython 3.0.2.0
python 2.7.10

How to add Toolbar Button to Title Bar

I have created a toolbar via IB and have a simple View menu with the "Show Toolbar" and "Customize Toolbar" menu items. Both work exactly as I would like them to.
But, I cannot seem to get the Toolbar Button to show up in the title bar of the NSWindow.
I have tried setting the "Shows Toolbar Button" in IB... no luck.
I have tried calling setShowsToolbarButton in the window controller's awakeFromNib
NSLog(#"showsToolbarButton: %#\n",[[self window]showsToolbarButton]?#"YES":#"NO");
[[self window]setShowsToolbarButton:YES];
NSLog(#"showsToolbarButton: %#\n",[[self window]showsToolbarButton]?#"YES":#"NO");
Again, no luck. Both log entries show "NO" and there is no button.
Has this feature gone away?
If not, what is the proper way to get that button to show up?
I'm building for OSX 10.6 and newer using Xcode 5.0.2 on a machine running 10.9.
Thanks for any/all insights.
The button to hide and show the toolbar was commonly seen as a small capsule button in the upper right corner at least through 10.6 Snow Leopard.
It is no longer present in standard OS X windows.
Ostensibly this is still in Xcode for supporting projects targeting older versions of OS X.
You can probably still create your own button and set its action to the same selectors, but you would likely need to create a custom window using NSBorderlessWindowMask to get the button in the title bar where it used to be.
In its place for the last several OS X versions you will find the full screen button instead.

Customize the Apple Menu

How to customize the Apple menu? What SDKs should I study, etc.? I want to insert a menu item:
Apple Menu Specific
This AskDifferent question addresses removing an item from the Apple menu. Seems you could use the same technique to add an item. Just be sure to make a backup of any system files you edit.
The following posts recommend similar solutions but are a bit dated. The system file path appears to be the same, however.
Hide unwanted Apple menu items
Remove the 'Get Mac OS X Software' menu item
Also mentioned in the AskDifferent quesiton, FruitMenu allows for menu customization. However, there's no support for the more current versions of OS X.
Version 3.8.4 released Mar 3, 2011
Requires Mac OS X 10.5.8 or Mac OS X 10.6.x; Rosetta
Compatible with Mac OS X 10.6 Snow Leopard.
OS X Menu Item Tutorials
Creating a Standalone StatusItem Menu 1
This tutorial will show you how to create a StatusItem menu that will be available to all applications in the menu bar.
When you are done, you will have a simple menu that will appear on its own in the menubar as a "universal" background application, and will contain two menu items that let you enter a string into the Console and Quit itself. Note that you will need to code the functionality yourself for any menu item(s) you add or modify, but this will get you started.
Creating a Status Bar Application
This tutorial assumes you have a basic knowledge of Objective-C. In this tutorial, we will walk-through on how to create a status bar only application for the Mac OS X.
1 Mac Menu Bar Tutorial?
It is simply a folder named "Apple Menu Items" in the System Folder which you can manipulate in many ways. But don't rename it or move it out of the System Folder.
http://www.macoptions.com/os85/applemenu.html

How to set an OSX application dock icon in XCode?

So far the only working solution I have found is to use:
[NSApp setApplicationIconImage: myImage];
But this message is sent after the default icon is already in the dock, so it's not working: the icon is initially set to the default application icon. I have not found the correct place to send this message.
I have read this: How can I set the icon for a Mac Application in Xcode? but it seems a bit too old to be useful for XCode 4.3
What is the standard way to set the dock icon, and even more importantly, where in the documentation is this described ?
I have trashed 4.3 two days ago, so I am using 4.5 developer preview to explain, but it should be similar.
Open up you project
In the left inspector be sure you are in the project navigator
Click the top node which should be named like your project
The middel section should now show some summaries of your project
Click on your Project name under "Targets"
The middle section should now show some Tabs, get on "Summary"
Drag your Icon file to the App Icon field.
Hope that helps.

Resources