How to make an application responsive to screen DPI/Resolution?
-
Hey there,
First of all, happy 2022 to everybody! :)
Guys, I was wondering the best approach to make my app be responsive to different screen sizes. I'm working on a major version of my tool and the main goal is to do a complete UI review including high-resolution assets (icons, images, background, etc) and make the software adjust the widget sizes according to the current resolution.
I'm aware of Qt's magic tricks on this subject (https://doc.qt.io/qt-5/highdpi.html), but one thing bothers me... When using, for example,
QT_SCALE_FACTOR
with a value greater than 1 the UI is exaggeratedly resized (in my case) causing a not so optimized use of all the available screen size. For example:The image below is my app running on a 4K screen without using
QT_SCALE_FACTOR
. What I would like to do is to "automagically" increase the size of icons, toolbars and so on without scaling the entire UI.Now, when I use QT_SCALE_FACTOR on the same screen the result is:
So, my question is, if there's a way to scale things without appealing to
QT_SCALE_FACTOR
how to do that? I was thinking of testing a silly solution that is iterating over the widget's children and resizing only those belonging to certain classes (QToolButton, QPushButton). Does this make sense? Is there a way to use the scale routines implemented by Qt in the way I need?Thanks in advance.