#include "widget.h"#include <QApplication>#include <QObject>#include <QWidget>#include <QDesktopWidget>#include <QMessageBox>//#include <stdio.h>//#include <string>#include "windows.h"#pragma comment(lib,"User32.lib")#pragma execution_character_set("utf-8")int main(int argc, char *argv[]){ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);//控制图片缩放质量 //QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); //qreal cx = QApplication::desktop()->width(); //QMessageBox::information(nullptr, QString::number(cx),QString::number(cx)); //qreal scale = cx / 1920; //if(scale > 0.7) scale = 1.0; //qputenv("QT_SCALE_FACTOR", QString::number(scale).toLatin1()); //qputenv("QT_SCALE_FACTOR", "1.0"); //qputenv("QT_ENABLE_HIGHDPI_SCALING", "1"); //QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); //qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1.0"); QApplication a(argc, argv); DEVMODE devmode; //memset(&devmode, 0, sizeof (devmode)); //devmode.dmSize = sizeof(DEVMODE); //devmode.dmDriverExtra = 0; BOOL Isgetdisplay = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode); QMessageBox::information(nullptr, "QString::number(devmode.dmPelsWidth)",QString::number(devmode.dmPelsWidth)); Widget w; w.show(); return a.exec();}