jwu
10th December 2017, 17:58
cross posting from [URL="https://stackoverflow.com/questions/47740565"]stackoverflow:
The following C++/Qt code is used to launch a modal dialog that prompts for a file selection:
QFileDialog dlg(parent, caption, dir, filter);
dlg.setOption(QFileDialog::DontUseNativeDialog);
dlg.setViewMode(QFileDialog::Detail);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setReadOnly(true);
dlg.setProxyModel(new OpenFileProxyModel);
dlg.setFileMode(FileDialog::ExistingFiles);
if (dlg.exec())
return dlg.selectedFiles();
This is correctly executed. Then, however, the calling application proceeds to load the selected files, and updates a file list in the main window - before the modal dialog is properly closed. This results in a badly disfigured transient display. Part of the QFileDialog remain visible, while others are overwritten by updated parts of the main window.
How to prevent this behavior?
Other discussion threads suggest
qApp->processEvents();
which, however, has no effect here.
The following C++/Qt code is used to launch a modal dialog that prompts for a file selection:
QFileDialog dlg(parent, caption, dir, filter);
dlg.setOption(QFileDialog::DontUseNativeDialog);
dlg.setViewMode(QFileDialog::Detail);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
dlg.setReadOnly(true);
dlg.setProxyModel(new OpenFileProxyModel);
dlg.setFileMode(FileDialog::ExistingFiles);
if (dlg.exec())
return dlg.selectedFiles();
This is correctly executed. Then, however, the calling application proceeds to load the selected files, and updates a file list in the main window - before the modal dialog is properly closed. This results in a badly disfigured transient display. Part of the QFileDialog remain visible, while others are overwritten by updated parts of the main window.
How to prevent this behavior?
Other discussion threads suggest
qApp->processEvents();
which, however, has no effect here.