c++ - 为什么应用程序无法在高 DPI 屏幕上缩放?
问题描述
我正在笔记本电脑上使用 qt 开发一个应用程序,具有 125% 的缩放比例。我搜索了扩展应用程序的网络方法。我习惯了:
- QT_AUTO_SCREEN_SCALE_FACTOR=true
- QT_ENABLE_HIGHDPI_SCALING=真
- QT_SCALE_FACTOR=1
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
这些方法中没有一种是没有效果的。
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 位调试。
解决方案
我重新启动Qt 并且缩放开始工作。编辑环境变量后也需要重新启动。
推荐阅读
- node.js - 是否可以仅使用一个请求来获得两个 nodejs 服务器之间的 RTT 延迟?
- javascript - 如何从javascript中的对象获取特定的键值?
- google-cloud-platform - Google Cloud Dataflow 写入 BigQuery(错误 401:需要登录)
- python - 直接从命令行在 IDLE 窗口中运行文件
- android - Android Gradle 同步错误:读取超时
- php - 命名空间 + 框架 + 作曲家
- c++ - 错误:数组下标的类型“int [int]”无效
- jquery - 展开/折叠嵌套中继器
- python - 在 Python 中对变量进行 bin 处理的有效方法
- django - 在模板中使用带有 django 选择字段的 if 条件