Fixing Qt 4 for Mac OS X 10.9

Mac OS X 10.9 (Mavericks) was released yesterday. And those nice people at Apple made it free, so you can be sure lots of people are downloading it. However Qt 4 apps look at bit strange on the new OS. Look at the text alignment in these buttons:

buttons1The text isn’t centre aligned. It doesn’t look like much of an issue out of context. But it looks wrong when you look at a whole UI. The good news is that there is a simple fix:

#ifdef Q_OS_MACX
    if ( QSysInfo::MacintoshVersion > QSysInfo::MV_10_8 )
        // fix Mac OS X 10.9 (mavericks) font issue
        QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");

You need to place this code in your main() before creating your QApplication. For more details see this bug report.

With the fix the buttons look like this:

buttons2Much better! There are some console warnings:

CoreText performance note: Client called CTFontCreateWithName() using
name "Lucida Grande" and got font with PostScript name "LucidaGrande". 
For best performance, only use PostScript names when calling this API.

I am not sure how how significant these are.

I have also found that updating to Qt 4.8.5 fixes a printing crash bug in my table plan software. This crash happened when rotated pixmaps were printed from Mac OS X 10.8.

I have seen on forums that Qt 5 is completely broken on 10.9. But I don’t know if that is true.

19 thoughts on “Fixing Qt 4 for Mac OS X 10.9

    1. Andy Brice Post author

      I updated XCode at the same time and I had to do a fair bit of buggering around to get building again. Hints:
      -reset the compiler in projects>build and run>kit (or something like that)
      -start xcode and accept the agreement

      1. Andy Brice Post author

        Sorry, I didn’t make that very clear. I could get my product to build against Qt 4.8.5 on 10.8. But I couldn’t get 4.8.5 to build on 10.9.

  1. john

    We’ve also found a bug associated with QDir::currentPath() returning the correct path name for the location of the running Qt application. Any suggestions for a work around for this?

    1. Andy Brice Post author

      Just had a quick play with PerfectTablePlan on 10.9 and there does seem to be a problem. Ugh. I hope Digia can come up with a version of Qt 4 that work ok on 10.9 soon.

  2. Andy Brice Post author

    I am trying to build Qt 4.8.5 on 10.9 with the very latest release of Xcode. It fails building webkit (which I don’t use). So I am trying to build it again with:

    configure -no-webkit

    I am getting 1000s of “this version of Mac OS X is not supported” warnings.

    1. Andy Brice Post author

      The 4.8.5 build now fails with: error: use of undeclared identifier

      It looks like these problems were known about months ago:

      I guess I will have to hope for Qt 4.8.6 that fixes these various issues on 10.9. Not very happy. Digia seem to have dropped the ball here. It isn’t as if they haven’t had ages to prepare for 10.9. But there is nothing on .

  3. Andy Brice Post author

    I tweeted qtproject and this is there response:

    @successfulsw We’ve been thinking of making a 4.8.6 release, but we can’t promise fixing all Mac 10.9 issues.

    Not very encouraging. If they weren’t intending to support 10.9 on Qt 4 then I wish they had announced this months ago, so I had time to move my app to Qt 5.

    1. john

      I also discovered a work around while still staying with using Qt calls.
      QApplication::applicationDirPath() appears to work properly on OSX 10.9 Mavericks. So using that and QDir cdUp() 3 times will get you the application folder, since it returns the executable location inside of the mac app bundle.
      This works for Qt4.

  4. L. Hill

    Thanks for the post. Qt 5.1.1 works fine on OS X 10.9 release version, except for this same font problem. Previous versions of Qt 5.x would crash.

    1. Andy Brice Post author

      Same issue for QFileDialog::getOpenFileName(). You can work around it by passing in the QFileDialog::DontUseNativeDialog flag. But this means you get the ugly non-native dialogs.

    2. john

      QFileDialog::getSaveFileName() works for me as you would expect. I keep a QString around that contains the last directory used.

Comments are closed.