Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.15, 6.2.9, 6.5.2
-
Pixel 4 Emulator, API 31
-
-
1989e419a (tqtc/lts-6.5)
Description
It looks like when multiple nameFilters are specified, only the first one is applied.
Code
import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Dialogs 1.3 // Remove version number to run on Qt 6 Window { visible: true FileDialog { id: dialog onAccepted: console.log("Selected", dialog.fileUrl) } Column { Button { id: b1 text: "*.txt only" onClicked: { dialog.nameFilters = ["(*.txt)"] dialog.open() } } Button { id: b2 text: "*.csv only" onClicked: { dialog.nameFilters = ["(*.csv)"] dialog.open() } } Button { id: b3 text: "*.txt and *.csv" onClicked: { dialog.nameFilters = ["(*.txt)", "(*.csv)"] dialog.open() } } Button { id: b4 text: "*.csv and *.txt" onClicked: { dialog.nameFilters = ["(*.csv)", "(*.txt)"] dialog.open() } } Button { id: b5 text: "*.txt and *.invalid" onClicked: { dialog.nameFilters = ["(*.txt)", "(*.invalid)"] dialog.open() } } Button { id: b6 text: "*.invalid and *.txt" onClicked: { dialog.nameFilters = ["(*.invalid)", "(*.txt)"] dialog.open() } } } }
Steps to reproduce
- On the Android device, use a web browser to download a *.txt and a *.csv file (samples attached)
- Build and run the code above
- Click each button and use the file picker to view/select the files you downloaded in Step #1
Outcomes
Button | Expected selectable | Actual selectable | Result |
---|---|---|---|
b1 | *.txt | *.txt | Pass |
b2 | *.csv | *.csv | Pass |
b3 | *.txt and *.csv | *.txt | Fail |
b4 | *.txt and *.csv | *.csv | Fail |
b5 | *.txt | *.txt | Pass |
b5 | *.txt | (nothing) | Fail |
Workaround
Specify the file extensions as a single filter. Replace ["(*.txt)", "(*.csv)"] with ["(*.txt, *.csv)"]