11

My software runs on Windows 7 and up and was developed with 100% dpi scaling (Control Panel > Make text and other items larger or smaller) with Qt 5.8.

When my users have their dpi scaling set to something like 150%, all the text and layout spacing increases in size, as they should, but EVERYTHING ELSE is untouched.

The result is a broken GUI with text way too big for the other elements.

I've researched as much as I could and the "simple fix" is to set the environment variable QT_AUTO_SCREEN_SCALE_FACTOR to true.

qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); is what I added as the first line in my main.cpp.

Absolutely no effect whatsoever. The only thing that has any effect at all is qputenv("QT_SCALE_FACTOR", "1.5"); however this is definitely not what I want at all.

How can I tell the rest of my software to scale accordingly?

Thanks for your time!

EDIT:

This is my bug https://bugreports.qt.io/browse/QTBUG-55654

mrg95
  • 2,371
  • 11
  • 46
  • 89
  • `QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);` also has no effect – mrg95 Dec 01 '17 at 06:36
  • I would also like to point out that about half of my GUI was created with Qt Designer and the rest was coded. Both behave the same. (I guess I would have expected even Qt Designer created elements to scale, but they don't) – mrg95 Dec 01 '17 at 06:40
  • I recently googled this topic and found a lot of similar issues as well as some work-arounds: What I considered the most worth I left open in browser tabs (but I just needed about 15 min. to find them again): [SO: Changing DPI scaling size of display make Qt application's font size get rendered bigger](https://stackoverflow.com/q/20464814/7478597), [Setting Qt To Ignore Windows DPI Text Size Personalization](http://www.charlesodale.com/setting-qt-to-ignore-windows-dpi-text-size-personalization/). – Scheff's Cat Dec 01 '17 at 10:08
  • Okay so one thing to note, I tried it on a different device (Windows 10 lenovo flex 5) where the dpi is higher by default. Turns out it did automatically scale it BUT, it scaled it by 2 instead of 1.5 which is what the device is set to. The result is that the text gets bigger by 1.5 but everything else gets increased by 2. It only takes integers looks like. I'm not sure what to do from here... – mrg95 Dec 01 '17 at 10:47
  • ??? I somewhere saw that Qt 5.10 is out. (or just in development?) As they hopefully try to fix this known issue, it would be worth at least a glance into the release-notes. – Scheff's Cat Dec 01 '17 at 10:49
  • Wouldn't help me anyway. My software is released on 5.8 anyway. From more testing, it definitely rounds to the closest integer. 1.25 goes to 1. 1.5 goes to 2. 1.75 goes to 2. and so on. – mrg95 Dec 01 '17 at 10:51
  • Still no option in Qt 5.10. This bug report is also interesting: https://bugreports.qt.io/browse/QTCREATORBUG-16293 – matthieu Dec 08 '17 at 19:06

1 Answers1

2

It is a little bit late may be for an answer but it may help.

Here is what was working for me. You can set DPIawareness manually by giving a command line option at the instanciation of the QApplication.

The official documentation is here https://doc.qt.io/qt-5/highdpi.html (section DPI awareness).

According to the documentation, you can set the application to DPI Unaware (thus it will automatically scale but display will be blurred), or to System DPI Aware or to Per-Monitor Aware.

Here is a minimal example code for the instanciation of the QApplication to force DPI Unaware (and have UI bitmap scaling) , choose other value than 0 to enable High DPI correctly:

int main() 
{
   int argc = 3;
   char*argv[] = {(char*)"Appname", (char*)"--platform", (char*)"windows:dpiawareness=0";
   (void) new QApplication(argc, argv);
}
Pat. ANDRIA
  • 2,330
  • 1
  • 13
  • 27