Menu

#79 QT issue - scaling problems on high dpi displays

v1.0_(example)
closed
None
5
2024-04-03
2024-03-27
No

The program is not scaled correctly on high-dpi displays. The fonts are very small and grainy. The following patch fixes the problem and works on regular displays as well:

Index: Main.cpp
===================================================================
--- Main.cpp    (revision 957)
+++ Main.cpp    (working copy)
@@ -90,7 +90,11 @@


 int main(int argc, char *argv[]) {
+    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
     QApplication qapp(argc, argv);
+    QFont f = qapp.font();
+    f.setPointSize(9);
+    qapp.setFont(f);
     qRegisterMetaType<std::vector<std::vector<double>>>("std::vector<std::vector<double>>");
     int guimode = 0;       // 0=normal, 1- r option, 2- app option
     QString localecode;        // either lang or the system localle - stored on mainwin for help display

Discussion

  • Jim Reneau

    Jim Reneau - 2024-04-03
    • status: open --> closed
     
  • Jim Reneau

    Jim Reneau - 2024-04-03

    Added to 2.0.99.10 (960) and committed

     

Log in to post a comment.