diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index d007f1afc9..d85a2a8b0e 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1271,12 +1271,9 @@ QStringList QFileDialog::selectedFiles() const QStringList files; const QList userSelectedFiles = d->userSelectedFiles(); files.reserve(userSelectedFiles.size()); - for (const QUrl &file : userSelectedFiles) { - if (file.isLocalFile() || file.isEmpty()) - files.append(file.toLocalFile()); - else - files.append(file.toString()); - } + for (const QUrl &file : userSelectedFiles) + files.append(file.toString(QUrl::PreferLocalFile)); + if (files.isEmpty() && d->usingWidgets()) { const FileMode fm = fileMode(); if (fm != ExistingFile && fm != ExistingFiles) @@ -2193,12 +2190,8 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, filter, selectedFilter, options, schemes); QStringList fileNames; fileNames.reserve(selectedUrls.size()); - for (const QUrl &url : selectedUrls) { - if (url.isLocalFile() || url.isEmpty()) - fileNames << url.toLocalFile(); - else - fileNames << url.toString(); - } + for (const QUrl &url : selectedUrls) + fileNames.append(url.toString(QUrl::PreferLocalFile)); return fileNames; }