QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
DEVMODE NewDevMode;
EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &NewDevMode);
qreal cx1 = NewDevMode.dmPelsWidth; //当前设置的屏幕宽度
qreal scale2 = cx / 1920.0;
qputenv("QT_SCALE_FACTOR", QString::number(scale2).toLatin1());
注意:
1.以上代码需加main函数中
2..pgn后缀的图片需修改为.svg