Qt程序适配4K分辨率高清屏幕
只需要再main.h中添加
//适配高清屏幕 #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif
附:main.h
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { //适配高清屏幕 #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }