10

I'm writing a C++ graphical application using Qt 5.5.0 on OS X El Capitan on a Retina MacBook Pro. Text is pixelated throughout the application so I suspect that high DPI mode is not used. My Info.plist contains the following definition:

<key>NSHighResolutionCapable</key>
    <true/>

How do I enable high resolution mode (especially for text rendering) in a Qt application on OS X?

SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87

2 Answers2

6

Make sure your info.plist has the NSPrincipalClass and NSApplication keys. According to the Qt docs, NSHighResolutionCapable is optional and true by default. Here's my entire plist for reference:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
    <key>NSPrincipalClass</key>
    <string>NSApplication</string>
    <key>CFBundleIconFile</key>
    <string>@ICON@</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleGetInfoString</key>
    <string>Created by Qt/QMake</string>
    <key>CFBundleSignature</key>
    <string>@TYPEINFO@</string>
    <key>CFBundleExecutable</key>
    <string>@EXECUTABLE@</string>
    <key>CFBundleIdentifier</key>
    <string>com.my.@EXECUTABLE@</string>
</dict>
</plist>

If you insist on specifying NSHighResolutionCapable manually, note that you did it wrong in your question. Here's the right syntax from the same docs:

<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • I tried your plist and manually correctly specifying `NSHighResolutionCapable` but it's still blurry/pixelated. – SurvivalMachine Dec 25 '15 at 19:29
  • 2
    After testing some more, your answer is actually correct. My running directory contained an old copy of the .plist. Manually setting `NSHighResolutionCapable` was not necessary. – SurvivalMachine Dec 25 '15 at 19:39
  • @SurvivalMachine: unless you need it, I'm fairly sure you can throw the plist away entirely. Should work without it as well. – Violet Giraffe Dec 25 '15 at 20:30
  • Big thank you... super obvious (sarcasm, many thanks to Apple) add NSPrincipalClass equal to NSApplication and it indeed started to work. – dev_null Mar 08 '18 at 13:39
3

You also need to call QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps) just after creating QApplication object to be able to use High DPI pixmaps. Read more here: http://doc.qt.io/qt-5/qpixmap.html#devicePixelRatio

Sergei Kulik
  • 344
  • 2
  • 9