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

QFileDialog does not work when run inside an QEventLoop with ExcludeUserInput set

    XMLWordPrintable

Details

    Description

      I have a program which disables user inputs at some point to be able to queue them for later. This works fine till I try to show a file dialog (see the attached sample), which (simplified) boils down to:

      mainwindow.cpp
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          connect(ui->pushButton, &QPushButton::clicked, []() {
              QEventLoop* loop = new QEventLoop;
              QTimer::singleShot(1000, [loop]() {
                  QFileDialog::getOpenFileName(qApp->activeWindow(), "test", "/tmp");
                  loop->quit();
                  loop->deleteLater();
              });
              loop->exec(QEventLoop::ExcludeUserInputEvents);
          });
      }
      

      This seems to work on windows but fails horribly on Linux with Glib (window does not paint properly nor reacts to user input). Since QFileDialog internally uses a new eventloop which does not exclude user inputs, I do not understand why this happens. Is this a bug in Qt, are nested event loops like that just not supported, or…? I do realize that my usage here is kinda odd, but I do not see why it could not work.

      Attachments

        Issue Links

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

          Activity

            People

              paeglis Gatis Paeglis
              apollo13 Florian Apolloner
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes