[Development] Confused about HiDPI scaling and fonts

Morten Sørvig Morten.Sorvig at qt.io
Tue Feb 9 16:08:05 CET 2021


Hello!

(This is mailing list is for discussing development _of_ Qt - interest at qt-project.org is the correct list for Qt usage questions)

The setting looks correct and fonts should be resized. There is no need to set QT_ENABLE_HIGHDPI_SCALING on the environment when setting the AA_EnableHighDpiScaling app attribute.

It’s a bit hard to say what goes wrong. You could try running qtdiag or dprgadget from github.com/msorvig/qt-highdpi-manualtests/tree/master/dprgadget and check if the correct device pixel ratio is set. (1.5 for 150% etc.)

- Morten


> On 8 Feb 2021, at 10:17, Thomas Laguzzi <tholag at gmail.com> wrote:
> 
> Hello,
> 
> I'm trying to enable QT_ENABLE_HIGHDPI_SCALING=1  in a windows application. It seems to work good in a multi-screen application even with different DPI settings, but it only resizes the widgets.
> The fonts always remain the same size (100% scaling).
> Is there a way to use QT_ENABLE_HIGHDPI_SCALING and automatic font resize? 
> If I have to do manually, how to detect screen changes?
> 
> If I use QT_SCALE_FACTOR  it resizes correctly both the widgets and fonts, but once the application is started it cannot be changed anymore.
> 
> I use something like:
>   qputenv("QT_ENABLE_HIGHDPI_SCALING","1");
>   
> QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
> QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
> QApplication a(argc, argv);
> MainWindow w;
> w.show();
> 
> thanks for any hint!
> Thomas
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development



More information about the Development mailing list