How to check screen dpi before a QApplication exists?
Solved
General and Desktop
-
Hi
I have no hires screen to test on so just asking.
You are saying that#include "mainwindow.h" #include <QApplication> #include <QScreen> int main(int argc, char *argv[]) { QApplication a(argc, argv); if ( a.screens().at(0)->geometry().width() > 2000) // 2000 is just random value. QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); else { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, false ); } MainWindow w; w.show(); return a.exec(); }
Does not fix the issue , turn on/off the scaling ?
-
-
Hi
Oddly enough i installed Qt5.6 and tried on windows 10 but
didnt change the Widgets even with (Qt::AA_EnableHighDpiScaling, true);Anyway, i was wondering if a workaround would be
int main(int argc, char *argv[]) { bool EnableHighDpiScaling = false; { QApplication a(argc, argv); if ( a.screens().at(0)->geometry().width() > 1090) // check somehow. DPI i assume EnableHighDpiScaling = true; } QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, EnableHighDpiScaling); QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
It cost an extra construction of a QApplication but the added startup time should be negligible ?