improper scaling of Qt Desktop application in windows 10

被刻印的时光 ゝ 提交于 2019-12-04 05:00:02

Qt has recently released a blog post about this issue here.

High DPI support is enabled from Qt 5.6 onward. On OS X platforms, there is native support for High-DPI. On X11/Windows/Android, there are two methods to enable high-DPI detection per the blog post:

  1. Set an environment variable
  2. Setting an attribute in the program source code

Setting QT_AUTO_SCREEN_SCALE_FACTOR=1 in your system environment variables will fix the scaling issue.

Additionally, setting QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); in your application source code should also allow automatic high-DPI scaling.

NOTICE: To use the attribute method, you must set the attribute before you create your QApplication object, that is to say:

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

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