Can I set QT_AUTO_SCREEN_SCALE_FACTOR behavior via API?

核能气质少年 提交于 2020-01-11 10:41:31

问题


Can I set the QT_AUTO_SCREEN_SCALE_FACTOR 1 behavior via an API call rather than by the environment variable? I want to detect if my Qt application is running on a high dpi screen, then set the scaling accordingly.

I have tried to set it at the very beginning of main, which does not work

QProcessEnvironment::systemEnvironment().insert("QT_AUTO_SCREEN_SCALE_FACTOR", "1");

It's meant to be used along with QProcess, to set the environment for child processes. It cannot be used to change the current process's environment.

Follow up of Style sheets / Qt Designer support for high dpi screens?


回答1:


The following should work

qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");



来源:https://stackoverflow.com/questions/35877420/can-i-set-qt-auto-screen-scale-factor-behavior-via-api

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