說到這個問題,我們要用到QT_REQUIRE_VERSION這個宏,Qt文檔中這麼描述:
這裏是要設置當前開發的Qt版本相匹配。
比如我用的是Qt5.6.0,所以在main.cpp上要這樣寫:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QT_REQUIRE_VERSION(argc, argv, "5.6.0");
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);//解決Qt在Retina屏幕上圖片模糊問題
MainWindow w;
w.show();
return a.exec();
}
核心代碼:
QT_REQUIRE_VERSION(argc, argv, "5.6.0");
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);//解決Qt在Retina屏幕上圖片模糊問題