QT_AUTO_SCREEN_SCALE_FACTOR has no effect

天涯浪子 提交于 2020-05-25 19:58:48

问题


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


回答1:


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);
}


来源:https://stackoverflow.com/questions/47587874/qt-auto-screen-scale-factor-has-no-effect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!