2

I'm trying to add support for High DPI scaling to my Qt6 application. For this I added an @2x set of icons, which are used when scale factor is 200%. But platforms like Windows also have intermediate scale factors like 150%, and rounding up or down via Qt::HighDpiScaleFactorRoundingPolicy would yield too large or too small GUI.

Apparently, Qt doesn't support icon sets like @1.5x, so it has to use the @2x set downscaled. But for some reason the downscaling results in a very pixelated image, as if it was nearest-neighbor interpolated. See the screenshot of a run with QT_SCALE_FACTOR=1.5 environment variable:

The code that resulted in this is here:

#include <QCheckBox>
#include <QApplication>

int main(int argc, char** argv)
{
    QApplication app(argc, argv);

    QCheckBox cb("Check me");
    cb.setChecked(true);
    cb.setStyleSheet("QCheckBox::indicator:checked { image: url(checkbox.png); }");
    cb.show();

    return app.exec();
}

The icons are as follows:

  • checkbox.png
  • checkbox@2x.png

My question is: how are we supposed to handle non-integral scaling factors if not by rounding them? Does Qt simply not support making them look "right"?

Ruslan
  • 18,162
  • 8
  • 67
  • 136

0 Answers0