Retina QPixmap



  • I am trying to support Retina displays for my applications via Qt 5.0.1 / MacOS X 10.8.3.

    Under Retina simulation, my application window and all widgets are drawn in High DPI but the pixmaps are pixellated and blocky.

    My interpretation of what I have read is that I can do this

    @
    QIcon about_icon(QPixmap(":/info.png"));
    about_icon.addPixmap(QPixmap(":/info@2x.png"));

    QToolButton about_button = new QToolButton;
    about_button->setIcon(about_icon);
    @

    I tried adding

    @qputenv("QT_HIGHDPI_AWARE", "1");@

    to my main widget constructor and also changing to

    @
    QIcon about_icon(QPixmap(":/info.png"));
    QPixmap about2x(":/info@2x.png");
    about2x.setDevicePixelRatio(2.0);
    about_icon.addPixmap(about2x);

    QToolButton about_button = new QToolButton;
    about_button->setIcon(about_icon);
    @

    but neither approach helps.

    My understanding was that a QPixmap loading a filename of the type "foobar@2x.ext" would automatically tag it as High DPI; but something is still missing here.



  • Simulating Retina on my laptop was doing my head in, so I now use a mini DisplayPort-HDMI cable connected to a 1920x1080 external monitor.

    When I move windows to the second display, Qt does not promote them; only system window decorations get promoted to HighDPI.



  • qApp->devicePixelRatio() reports a value of 2 under simulation.

    If I create a QIcon with a single 2x pixmap, with setDevicePixelRatio(2), I still get pixellated icons -

    @
    QIcon about_icon;
    QPixmap about2x(":/info@2x.png");
    about2x.setDevicePixelRatio(2);
    about_icon.addPixmap(about2x);
    @



  • I found this document in source https://qt.gitorious.org/qt/qtbase/blobs/da6bdffdcdb57669af13cfd531151fe0abc05be3/src/gui/doc/src/highdpi.qdoc

    but I can't see where this comes from or what versions it affects.

    Trying export QT_EMULATED_HIGHDPI=1 has no effect.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.