Qt will extract the default extension from the "selectedFilter" parameter, if specified.
Here is an example:
QString filter = "Worksheet Files (*.abd)"; QString filePath = QFileDialog::getSaveFileName(GetQtMainFrame(), tr("Save Worksheet"), defaultDir, filter, &filter);
When using this code, the getSaveFileName () method will automatically add the .abd file extension if the user did not specify it in the dialog box. You can see the implementation of this in the qt_win_get_save_file_name () file inside the Qt source file qfiledialog_win.cpp.
Unfortunately, this does not work for the getOpenFileName () method.
source share