Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Font Scaling on High DPI Linux displays

    General and Desktop
    2
    4
    324
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DalePennington last edited by DalePennington

      I have an application that normally runs on classic DPI Linux displays. But sometime I need to run it on a workstation that has a High DPI display. When it does, the Font scaling causes all the text to be clipped and basically unreadable. My preference would be to keep the Font at the same size relative to the gui element sizes as on the classic DPI displays.

      I went to the QT reference on scaling and saw the bit about using the QT_AUTO_SCREEN_SCALE_FACTOR environment variable. However, setting that to 1 (as stated in the page) had no effect on the Font scaling, it still was clipped.

      Does anyone have an idea how I can fix this (without some major rewrites of my GUI code which we do not have the budget for). I am using QT 5.12.5 running on Redhat 8.4.

      Dale Pennington

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @DalePennington last edited by

        Hi @DalePennington
        seems like you have a "legacy" project at hand, when the version freeze was on 5.12 ?

        have you this in your code ?
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        preferably before the application instance creation

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        D 1 Reply Last reply Reply Quote 0
        • D
          DalePennington @J.Hilk last edited by

          @J-Hilk
          I used the environment variable, but I will try the option you gave.

          It is definitely a legacy app, originally written in QT4, where we used toe SetDPI functions in QX11Info (removed in QT5) to deal with the same problem.

          I will post back once I have tried that solution.

          Dale

          1 Reply Last reply Reply Quote 0
          • D
            DalePennington last edited by

            In my main routine I added to following 2 lines

            int main(int argc, char *argv[])
            {
                // Set up High DPI Scaling
                QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling,true);
            
                std::cout << "Enable High DPI Scaling to " 
                                 << (QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) ? "true" : "false") << std::endl;
            
               // Existing Code
               QApplication a(argc,argv);
               // rest of main
            }
            

            I still saw the same font scaling and clipping issue. As a possible alternative, I tried swapping out the AA_EnableHighDpiScaling with AA_Use96Dpi, but that did not change anything.

            Dale

            1 Reply Last reply Reply Quote 0
            • First post
              Last post