Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113767

Width of QFileDialog is altered by filters set in constructor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.15.9, 5.15.13, 6.5.0
    • None
    • Linux/X11, Windows

      When setting a filter in a QFileDialog's constructor, the width of the QFileDialog can be extremely large if one of the filters is long. I have tested this on an olde Qt (5.13.2) and the issue did not occur (the text was cut off, and use of ellipses was done in the dropdown). I'm not positive, but the issue may be related to https://bugreports.qt.io/browse/QTBUG-84615, however the workaround they proposed did not seem to address my issue.

       

      Example Code:

      #include <QApplication>
      #include <QFileDialog>
      #include <QString>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QString largeFilter = "Large filter (*.aaa *.bbb *.ccc *.ddd *.eee *.fff *.ggg *.hhh *.iii *.jjj *.kkk *.lll *.mmm *.nnn *.ooo *.ppp *.qqq *.rrr *.sss *.ttt *.uuu *.vvv *.www *.xxx *.yyy *.zzz *.111 *.222 *.333 *.444 *.555 *.666 *.777 *.888 *.999)";
      
          QFileDialog dialogA(nullptr, "Filter set in constructor", "", largeFilter);
          dialogA.setOptions(QFileDialog::DontUseNativeDialog);
          dialogA.show();
      
          QFileDialog dialogB(nullptr, "Filter set via setNameFilters");
          dialogB.setOptions(QFileDialog::DontUseNativeDialog);
          dialogB.setNameFilters({largeFilter});
          dialogB.exec();
          
          return a.exec();
      } 

      5.13.2 Results

      5.15.9 Results

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mcdongle Mike Baran
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes