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. QFileDialog is not scaled the same way as the QApplicaiton with high DPI monitor
QtWS25 Last Chance

QFileDialog is not scaled the same way as the QApplicaiton with high DPI monitor

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.14highdpiqfiledialog
5 Posts 2 Posters 1.0k 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.
  • J Offline
    J Offline
    johnyang
    wrote on last edited by
    #1

    I am developing an application to work with 4k monitor. I manged to get nicely scaled application with Qt5.14.2 with following code:

    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 
    QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 
    QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Ceil);
    

    However when I open a file dialog using QFileDialog::getOpenFileNames, the pop-up dialog looks a lot smaller. I even tried the following code to make sure it has the same font size as the whole application, but the resultant pop up still looks the same same:

    QFileDialog openFileDialog;
    QFont font = QApplication::font();
    font.setPointSize(8);
    openFileDialog.setFont(font);
    

    Any idea why this is happening and how to fix it?

    jsulmJ 1 Reply Last reply
    0
    • J johnyang

      I am developing an application to work with 4k monitor. I manged to get nicely scaled application with Qt5.14.2 with following code:

      QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 
      QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 
      QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Ceil);
      

      However when I open a file dialog using QFileDialog::getOpenFileNames, the pop-up dialog looks a lot smaller. I even tried the following code to make sure it has the same font size as the whole application, but the resultant pop up still looks the same same:

      QFileDialog openFileDialog;
      QFont font = QApplication::font();
      font.setPointSize(8);
      openFileDialog.setFont(font);
      

      Any idea why this is happening and how to fix it?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @johnyang said in QFileDialog is not scaled the same way as the QApplicaiton with high DPI monitor:

      getOpenFileNames

      This is a static method, changing font on a QFileDialog instance will not influence what getOpenFileNames shows.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      2
      • jsulmJ jsulm

        @johnyang said in QFileDialog is not scaled the same way as the QApplicaiton with high DPI monitor:

        getOpenFileNames

        This is a static method, changing font on a QFileDialog instance will not influence what getOpenFileNames shows.

        J Offline
        J Offline
        johnyang
        wrote on last edited by
        #3

        @jsulm any clue how to fix this issue?

        jsulmJ 1 Reply Last reply
        0
        • J johnyang

          @jsulm any clue how to fix this issue?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @johnyang You could try to pass QFileDialog::DontUseNativeDialog as options to QFileDialog::getOpenFileNames

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply
          0
          • jsulmJ jsulm

            @johnyang You could try to pass QFileDialog::DontUseNativeDialog as options to QFileDialog::getOpenFileNames

            J Offline
            J Offline
            johnyang
            wrote on last edited by
            #5

            @jsulm Looks like that is the only way to get the scaled widget correctly. Thanks!

            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