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

QFileDialog selectedFiles() not updated when currentChanged signal is emitted

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7.0
    • None
    • Linux/Wayland, Linux/X11

    Description

      I have created a custom QFileDialog:

      class MyDialog : public QFileDialog
      {
      public:
          MyDialog(QWidget* parent = nullptr) : QFileDialog(parent)
          {
              setAcceptMode(QFileDialog::AcceptOpen);
              setFileMode(QFileDialog::ExistingFiles);
              setOption(QFileDialog::DontUseNativeDialog);        
              std::cerr << "MyDialog created" << std::endl;            
              connect(
                      this, &QFileDialog::currentChanged, [&](const QString&) {                          
                          QStringList files = selectedFiles();             
                          std::cerr << "Selected files: " << std::endl;
                          for (const QString& file : files) {
                              std::cerr << file.toStdString() << std::endl;
                          }
              });
          }
      }; 

      When the currentChanged signal is emitted (whithout the dialog being accepted) the list that I get when calling selectedFiles(); is not updated.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            alemuntoni Alessandro Muntoni
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes