Windows High DPI with different screen DPIs

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Windows High DPI with different screen DPIs

Post by apeltauer »

Hi all,

during developing another qt application i came accross the following articel
https://vicrucann.github.io/tutorials/osg-qt-high-dpi/

Since i am working with a notebook and an external 4k screen, i am facing some display issues when it comes to the high DPI problematic.
I kwow that windows(10) does not fully support a high dpi scalling for all appplications. Some of them just look blurry, depending on what screen it is opened.

Also working with FC shows some minor display issues. I tried the code suggested in the articel. See the differents.
Capture.png
Capture.png (186.29 KiB) Viewed 2080 times
The Code change in src\Gui\Application.cpp line 1906

Code: Select all

#if QT_VERSION >= 0x050600
    //Enable automatic scaling based on pixel density of display (added in Qt 5.6)
    //QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    SetProcessDPIAware(); // call before the main event loop
    QApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
#endif
Maybe some windows user also can test and check if this improves the behaviour.

PS:
A set of links to dpi topics
https://forum.freecadweb.org/viewtopic.php?t=41193
https://forum.freecadweb.org/viewtopic.php?t=34916
https://forum.freecadweb.org/viewtopic.php?f=34&t=48719
User avatar
vanuan
Posts: 539
Joined: Wed Oct 24, 2018 9:49 pm

Re: Windows High DPI with different screen DPIs

Post by vanuan »

Please read the master plan:
https://wiki.freecadweb.org/HiDPI_support

The flag AA_EnableHighDpiScaling should only be disabled after the part two is complete. That is, first we should make sure that we get the correct font metrics from the system and rescale all the widgets in units of font size.

If we disable the flag AA_EnableHighDpiScaling right now, we'll have the issue of widgets not being scaled to fit the text, thus the text would be larger than the widget size. The most prominent example is the Navigation Cube: https://forum.freecadweb.org/viewtopic.php?f=3&t=42835

Instead of choosing the readable size and scaling the cube to fit it, they opted to introducing a new user option: https://github.com/FreeCAD/FreeCAD/pull/2967
Hacks like this lead to a bad UX and should be discouraged.

Disabling the AA_EnableHighDpiScaling might work fine for Windows where font metrics are rarely changed while on other systems (Linux) font sizes vary significantly and should be figured out first.
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Re: Windows High DPI with different screen DPIs

Post by apeltauer »

vanuan wrote: Fri Nov 20, 2020 3:29 am ...
Thanks for your feedback.
I forgot to mention that disabling the hidpi on qt should only happen when the os is windows. also the mentioned call "SetProcessDPIAware();" only works on windows.
User avatar
apeltauer
Posts: 399
Joined: Fri Aug 11, 2017 2:19 pm

Re: Windows High DPI with different screen DPIs

Post by apeltauer »

Post Reply