首页 > 解决方案 > 为什么应用程序无法在高 DPI 屏幕上缩放?

问题描述

我正在笔记本电脑上使用 qt 开发一个应用程序,具有 125% 的缩放比例。我搜索了扩展应用程序的网络方法。我习惯了:

这些方法中没有一种是没有效果的。

QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);位于主要功能:

#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //It is here.
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

QtCreator 4.13.2、Qt 5.15.1、MSVC2019 64 位调试。

标签: c++qtuser-interface

解决方案


重新启动Qt 并且缩放开始工作。编辑环境变量后也需要重新启动。


推荐阅读