GUI scaling

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
vedderb
Posts: 1
Joined: Wed Feb 26, 2020 10:15 am

GUI scaling

Post by vedderb »

Hi,

This is my first post here, but I have been following and using FreeCAD for many years - thanks for the amazing work! I'm using the latest appimage for 0.19 on Ubuntu 18.04, and for a few months the GUI scaling has been strange on my 14 inch laptop with a 2560x1440 screen resolution. Here is what it looks like:

Image

If I change the screen resolution to 1920x1080, open FreeCAD and then change it back to 2560x1440 it looks normal:

Image

I can tweak the settings to make most things look kind of ok (except some fonts), but then when I connect an external monitor everything is wrong as FreeCAD then uses the proper DPI settings. So right now my procedure to start FreeCAD is to change to screen resolution, start freecad, then change the resolution back, which is quite inconvenient.

As far as I can tell this commit causes the problem, as the DPI settings wouldn't be applied when set after starting the GUI, as it was before:

https://github.com/FreeCAD/FreeCAD/comm ... 190b5e46e2

I had similar issues when developing VESC Tool, and have not found a good way to make qt scale properly yet. The closest I got to an acceptable solution is this:

https://github.com/vedderb/vesc_tool/bl ... r/main.cpp

Code: Select all

QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // Omit this line, as it makes things worse
QCoreApplication::setAttribute(Qt::AA_Use96Dpi);
qputenv("QT_SCALE_FACTOR", 1.2); // Scale factor that user can choose, e.g. 1.2
It would be great to add an option to the settings to disable the Qt DPI scaling (Qt::AA_EnableHighDpiScaling), and possibly and option to use a scale factor environment variable (QT_SCALE_FACTOR).
Post Reply