[Interest] Mac with Retina Display - Look is "Pixilated" with Qt-5.4.2

Till Oliver Knoll till.oliver.knoll at gmail.com
Fri Jul 24 13:36:40 CEST 2015


> Am 22.07.2015 um 08:43 schrieb Robert Iakobashvili <coroberti at gmail.com>:
> 
> On Wed, Jul 22, 2015 at 9:16 AM, Hamish Moffatt
> <hamish at risingsoftware.com> wrote:
>> On 22/07/15 15:52, Robert Iakobashvili wrote:
>>> 
>>> Gentlemen,
>>> A user pointed to the issue on
>>> Mac Book Pro 15 inch mid 2015. AMD Radeon R9 graphic card,
>>> 15.4-inch, 2880 x 1800 screen, Mac OS 10.10.4.
>>> and mentioned that the look is "pixelated as the application
>>> does not support Retina".
>>> 
>>> Unfortunately, I do not have such expensive HW to
>>> reproduce the issue.
>>> 
>>> A patch to support 2x and 3x images
>>> from Morten Sorvig has been applied
>>> and images 2x and 3x are inside:
>>> 
>>> https://codereview.qt-project.org/106717
>>> https://codereview.qt-project.org/106705
>>> 
>>> Is there something else to be done with Qt-5.4.2
>>> like defining some HIGH-DPI, etc?
>> 
>> You need to add two keys to your Info.plist:
>> 
>> a boolean key NSHighResolutionCapable with value TRUE;
>> a string key NSPrincipalClass with value NSApplication.
>> 
>> 
>> Hamish
> 
> Dear Hamish,
> I'll try it.

Besides, you don't necessarily need Retina capable hardware: the "Quartz Debug Extensions" ((?) check optional developer downloads, either in Xcode or, more likely, on Apple's developer homepage) allow you to run your desktop in "Retina mode" to test your application.

Off course on a non-Retina display everything appears 2 times as big (and you effectively loose "desktop space" by the corresponding factor), but like this it is possible to visually "debug" your @2x resources and easily spot pixmaps with low resolutions etc.

And off course you easily detect whether your application has been enabled for Retina (see Info.plist related answer before).

Finally this is still a good starting point:

  http://blog.qt.io/blog/2013/04/25/retina-display-support-for-mac-os-ios-and-x11/

Note that in most cases you really just need to "enable Retina capability" and provide @2x resources (bitmaps). Qt will take care of the rest! Even if you draw with a QPainter Qt will do just fine (the coordinates are always measured in "points", under the hood QPainter converts them to "pixels" in the appropriate resolution - simplified).

Only if you really draw yourself "on a pixel level" (e.g. also OpenGL code which is /always/ pixel-based!) your drawing code needs to be aware of the actual resolution - and possibly switch/exchange bitmap resources on the fly, if the window is moved from a Retina to non-Retina display and vice versa.

Cheers,
  Oliver


More information about the Interest mailing list