I am trying to show a dialog box to open multiple files but seems like it is not working. The following is a function defined in my Class:
JavaScript
x
7
1
def loadFiles(self):
2
filter = "TXT (*.txt);;PDF (*.pdf)"
3
file_name = QtGui.QFileDialog()
4
file_name.setFileMode(QFileDialog.ExistingFiles)
5
names = file_name.getOpenFileNameAndFilter(self, "Open files", "C\Desktop", filter)
6
print names
7
I thought that the keyword was QFileDialog.ExistingFiles
.
What am I doing wrong here?
Advertisement
Answer
You need to use getOpenFileNamesAndFilter
instead of getOpenFileNameAndFilter
(you’re missing the s
).