QFileDialog to open multiple files

14,056

You need to use getOpenFileNamesAndFilter instead of getOpenFileNameAndFilter (you're missing the s).

Share:
14,056
codeKiller
Author by

codeKiller

Updated on June 09, 2022

Comments

  • codeKiller
    codeKiller about 2 years

    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:

    def loadFiles(self):
        filter = "TXT (*.txt);;PDF (*.pdf)"
        file_name = QtGui.QFileDialog()
        file_name.setFileMode(QFileDialog.ExistingFiles)
        names = file_name.getOpenFileNameAndFilter(self, "Open files", "C\\Desktop", filter)
        print names
    

    I thought that the keyword was QFileDialog.ExistingFiles.

    What am I doing wrong here?

  • codeKiller
    codeKiller over 9 years
    yes!!.....only for one stupid s the whole thing was not working....... :( Thanks friend!!