Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT_AUTO_SCREEN_SCALE_FACTOR has no effect

Tags:

c++

dpi

qt

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

like image 426
mrg95 Avatar asked Dec 01 '17 06:12

mrg95


1 Answers

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);
}
like image 92
Pat. ANDRIA Avatar answered Sep 19 '22 18:09

Pat. ANDRIA