QFileDialog::getOpenFileName Fails to Display Dialog with Native macOS
-
Hi Qt Devs! I'm developing a desktop application in C++ on macOS Sequoia 15.5 with Qt 6.9.1. When I call QFileDialog::getOpenFileName from a class that inherits from QWidget while on the main thread no dialog appears and the function immediately returns an empty string. When I call QFileDialog::getOpenFileName with the QFileDialog::DontUseNativeDialog option, however, I do indeed get a dialog and can retrieve a file name. I would like to use the native dialog, is there some reason the call is not displaying a file dialog with the native version?
In short, this code does not display a dialog on macOS:
QFileDialog::getOpenFileName(this, tr("Please select a file."));
But this code does display a dialog on macOS:
QFileDialog::getOpenFileName(this, tr("Please select a file."), QString(), QString(), nullptr, QFileDialog::DontUseNativeDialog);
Thanks!
Edit: The same problem occurs with QFileDialog::getSaveFileName and QFileDialog::getExistingDirectory too. Other calls like QMessageBox::information do work as expected, however.
-
Hi,
Please provide a complete minimal example that shows that issue. This will allow people to test in the same conditions as you.