Font Scaling on High DPI Linux displays
-
I have an application that normally runs on classic DPI Linux displays. But sometime I need to run it on a workstation that has a High DPI display. When it does, the Font scaling causes all the text to be clipped and basically unreadable. My preference would be to keep the Font at the same size relative to the gui element sizes as on the classic DPI displays.
I went to the QT reference on scaling and saw the bit about using the QT_AUTO_SCREEN_SCALE_FACTOR environment variable. However, setting that to 1 (as stated in the page) had no effect on the Font scaling, it still was clipped.
Does anyone have an idea how I can fix this (without some major rewrites of my GUI code which we do not have the budget for). I am using QT 5.12.5 running on Redhat 8.4.
Dale Pennington
-
I have an application that normally runs on classic DPI Linux displays. But sometime I need to run it on a workstation that has a High DPI display. When it does, the Font scaling causes all the text to be clipped and basically unreadable. My preference would be to keep the Font at the same size relative to the gui element sizes as on the classic DPI displays.
I went to the QT reference on scaling and saw the bit about using the QT_AUTO_SCREEN_SCALE_FACTOR environment variable. However, setting that to 1 (as stated in the page) had no effect on the Font scaling, it still was clipped.
Does anyone have an idea how I can fix this (without some major rewrites of my GUI code which we do not have the budget for). I am using QT 5.12.5 running on Redhat 8.4.
Dale Pennington
Hi @DalePennington
seems like you have a "legacy" project at hand, when the version freeze was on 5.12 ?have you this in your code ?
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
preferably before the application instance creation -
Hi @DalePennington
seems like you have a "legacy" project at hand, when the version freeze was on 5.12 ?have you this in your code ?
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
preferably before the application instance creation@J-Hilk
I used the environment variable, but I will try the option you gave.It is definitely a legacy app, originally written in QT4, where we used toe SetDPI functions in QX11Info (removed in QT5) to deal with the same problem.
I will post back once I have tried that solution.
Dale
-
In my main routine I added to following 2 lines
int main(int argc, char *argv[]) { // Set up High DPI Scaling QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true); std::cout << "Enable High DPI Scaling to " << (QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) ? "true" : "false") << std::endl; // Existing Code QApplication a(argc,argv); // rest of main }
I still saw the same font scaling and clipping issue. As a possible alternative, I tried swapping out the AA_EnableHighDpiScaling with AA_Use96Dpi, but that did not change anything.
Dale