Qt 4.7.2 - Mac OS X: Cmd+M doesn't minimize my application?!
-
On Mac OS X, to press Cmd+M should minimize the active application. At least, it does for Mac OS X applications that I have tried. However, when it comes to Qt applications, it varies from one application to another. For example, Qt Creator 2.1.0 does minimize, but qtdemo doesn't, and it's the same with my Qt application. I have created and compiled a very basic Qt application, and Cmd+M didn't work either, so that tells me that my application may not be the culprit. In fact, I have checked whether I use Cmd+M as a shortcut in my application, and I don't. Otherwise, thinking that Qt Creator 2.1.0 is compiled with Qt 4.7.1, I thought that maybe something got broken between 4.7.1 and 4.7.2, but I have recompiled my application with Qt 4.7.1 and I am still having the same problem.
So, as someone experienced / is experiencing the same problem? More importantly, does someone know how to fix this 'problem'?
-
Yep - Qt doesn't implement this default mapping. Apple called me on it when I submitted a Qt-based app to the Mac App Store.
Just implement your own shortcut and have it connected to the QMainWindow::showMinimized() slot.
Here is the exact line of code I added to my QMainWindow subclass:
@new QShortcut(QKeySequence("Ctrl+M"), this, SLOT(showMinimized()));@
Note that in Qt "Ctrl" is the same as "Cmd" on Mac.
-
Thanks for confirming what I thought might be the case, fxtech. While I am it, are you aware of any other similar mapping that Qt doesn't implement?
-
If you are developing for the Mac App Store be aware that by default QtCore writes "global" preferences in places it shouldn't (notably to the com.trolltech.plist file). You'll need to manually modify the QSettings code so it doesn't do this. But, this means you'll need to compile your own QtCore and ship it with your app, bundled as a private framework.
-
Oh also note that Qt puts Dock Widget "close" buttons on the right side of the dock titlebar. But on Mac, they need to be on the left. My reviewer was very anal about this and I had to modify my Dock Widgets to have a custom title-bar widget that had the close button on the left. Also you'll need to make sure Dock Window title labels are centered.
-
Ok, thanks god, I have no intention (for now, at least) to have my application on the App Store, but it's still very good to know! If anything, it shows that there is still room for Qt to improve its Mac OS X support (I am still very impressed with Qt though, considering that I work on Windows, Linux and Mac OS X, and that it has been pretty much a breeze to get things to work on all three platforms).
-
Did you raise a bug about the Dock Widget buttons on Mac?
-
No I never did. I was under the gun to get it working and had to move on to other stuff. I should be more diligent about stuff like this. I have filed bug reports about other things in the past though.