Wait in for loop till QDialog closes

  • Hi, this might be pretty simple but obviously i cant find the right words to get an answer from google.

    I got a QMainWindow and in a function which contains a for loop that runs through a QStringList with filenames.
    Now i want to generates a QDialog for each file that matches a QString in the filename.
    Pseudo Code:
    void MainWindow::somefunction()
    for (int i = 0; i < filelist.size(); i++)
    if (filelist.at(i).contains("xyz"))
    QDialog *newdialog = new QDialog(this);
    //here i need to wait for the dialog to be closed.

    The above pseudocode would create 1 Dialog for each file which could result in a lot of dialogs at the same time.
    What i want to achieve is that only 1 Dialog will be created and wait for it to close before proceeding with the loop.

  • Moderators

    This will work. QDialog does wait for QDialog::exec() to finish :)

  • Well the failure was a logical one that ended up in calling the whole function more than once.
    Thanks for the answer anyways.
    This thread can be closed.

Log in to reply