Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Font Scaling on High DPI Linux displays

Font Scaling on High DPI Linux displays

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.3k Views
  • 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 Offline
    D Offline
    DalePennington
    wrote on last edited by DalePennington
    #1

    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.HilkJ 1 Reply Last reply
    0
    • D 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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      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


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

      D 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        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

        D Offline
        D Offline
        DalePennington
        wrote on last edited by
        #3

        @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
        0
        • D Offline
          D Offline
          DalePennington
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved