I am trying to get files from filedialog and display the name of the file names inside the listview. And also checkboxes should also be created before the filenames inside the listview based on the number of files added. Below is my code that returns only one file with the check box, irrespective of any number of files selected. Help would be appreciated.
def OpenTheFile(self):
file = QtGui.QFileDialog.getOpenFileNames(self.dlg, "Select one or more files to open", os.getenv("HOME"),'.sql (*.sql)')
str_file = ','.join(file)
fileinfo = QFileInfo(str_file)
filename = QFileInfo.fileName(fileinfo)
if fileName:
for files in str_file:
model = QStandardItemModel()
item = QStandardItem('%s' % fileName)
item.setCheckable(True)
model.appendRow(item)
self.dlg.DatacheckerlistView2.setModel(model)
self.dlg.DatacheckerlistView2.show()