Retina support in Qt5 on OS X

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

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

How to enable high resolution (especially for text rendering) in a Qt application in OS X?

+8
c ++ qt macos retina
source share
2 answers

Make sure your info.plist has the NSPrincipalClass and NSApplication . According to Qt docs , NSHighResolutionCapable is optional and true by default. Here is all my 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 is the correct syntax from the same documents:

 <key>NSPrincipalClass</key> <string>NSApplication</string> <key>NSHighResolutionCapable</key> <string>True</string> 
+3
source share

You also need to call QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps) immediately after creating the QApplication object in order to be able to use High-DPI pixmaps. More details here: http://doc.qt.io/qt-5/qpixmap.html#devicePixelRatio

+1
source share

All Articles