[Interest] How are High DPI Icons supposed to work?

Julius Bullinger Julius.Bullinger at asctec.de
Mon Sep 28 09:27:49 CEST 2015

> Your code looks ok. You didn't say what the problem was?

You're right, I'm sorry for that. As you can see in the attached screenshot, the @2x icon is not actually used in a high DPI/DPR application:

    QPushButton* pbCustom = new QPushButton();
    pbCustom->setText(tr("QPushButton w/ pixmap"));
    pbCustom->setIconSize(QSize(48, 48));
    // ...

    QPushButton* pbCustom2x = new QPushButton();
    pbCustom2x->setText(tr("QPushButton w/ pixmap2x"));
    pbCustom2x->setIconSize(QSize(48, 48));
    // ...

This is with QT_DEVICE_PIXEL_RATIO set to both '2' and 'auto'. 

>> QPixmap pixmap2x(":/icons/48x48/icon at 2x.png");
>> pixmap2x.setDevicePixelRatio(2);
> You don't need to set the DPR manually, QPixmap will set it when it sees the @2x in the filename.

That's what I figured out after sending my mail. Thanks anyway!

Best regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2015_09_28_08_49_45_High_DPI_Icon_Test.png
Type: image/png
Size: 47145 bytes
Desc: 2015_09_28_08_49_45_High_DPI_Icon_Test.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150928/d922317f/attachment.png>

More information about the Interest mailing list