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 1 Jul 2020, 05:36 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?

    J 1 Reply Last reply 1 Jul 2020, 06:10
    0
    • J johnyang
      1 Jul 2020, 05:36

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Jul 2020, 06:10 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 Jul 2020, 00:06
      2
      • J jsulm
        1 Jul 2020, 06:10

        @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 2 Jul 2020, 00:06 last edited by
        #3

        @jsulm any clue how to fix this issue?

        J 1 Reply Last reply 2 Jul 2020, 04:21
        0
        • J johnyang
          2 Jul 2020, 00:06

          @jsulm any clue how to fix this issue?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 2 Jul 2020, 04:21 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 5 Jul 2020, 23:39
          0
          • J jsulm
            2 Jul 2020, 04:21

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

            J Offline
            J Offline
            johnyang
            wrote on 5 Jul 2020, 23:39 last edited by
            #5

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

            1 Reply Last reply
            0

            3/5

            2 Jul 2020, 00:06

            • Login

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