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

QFileDialog::setFileMode(QFileDialog::ExistingFiles) cannot select multiple items on Kubuntu.

    XMLWordPrintable

Details

    • Qt 5: b6ccdfa4823d4608f5cb94797b48fc82b8833581 Qt 4: e3cc56d532edc97291b4f5a6c95db8b0ed8b3fe8

    Description

      According to http://userbase.kde.org/Dolphin/File_Management#Introduction_to_Dolphin page, we can select multiple items using few methods mentioned.

      When you click the plus-sign, this file or folder will be added to your selection. You can select multiple files in the same way. Selection can be done also by dragging a rectangle (sometimes called the "rubber band" method), and selection and deselection with Ctrl + click for one at a time and Shift + click for a consecutive range.
      

      However, QFileDialog does not have the same behavior on the default file explorer to select multiple items. The only and strange way to select multiple items is by using the (optional, ctrl) click and drag, or sometimes called the "rubber band" method, to select multiple files.

      Test code:

      #if 1
          QFileDialog fooFileDialog;
          fooFileDialog.setDirectory(QDir::homePath());
          fooFileDialog.setFileMode(QFileDialog::ExistingFiles);
      
          QStringList fooFilters;
          fooFilters << "Any files (*)"
                     << "Image files (*.png *.xpm *.jpg)"
                     << "Text files (*.txt)";
          fooFileDialog.setNameFilters(fooFilters);
      
          if(fooFileDialog.exec())
          {
              //qDebug() << "File dialog closed. Selected files are listed below.";
              QStringList fooSelectedFiles = fooFileDialog.selectedFiles();
              foreach(QString fooFileName, fooSelectedFiles)
              {
                  qDebug() << "fooFileName:" << fooFileName;
              }
          }
      
      #else
          QStringList fooSelectedFiles =
                  QFileDialog::getOpenFileNames(0,
                                                "Select one or more files to open...",
                                                QDir::homePath(),
                                                "Any files (*)",
                                                0,
                                                QFileDialog::DontUseNativeDialog);
          foreach(QString fooFileName, fooSelectedFiles)
          {
              qDebug() << "fooFileName:" << fooFileName;
          }
      #endif
      

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              leonlee Leonard Lee
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes