I want to update the RowCount and fill it afterwards.
When trying to update the QTableWidgetItem with a given amount of Rows, it works.
However, when trying to populate these rows afterwards, nothing shows up in the GUI.
When removing the setRowCount() in my preview Function and instead using self.PreviewTable.setRowCount(4) directly after creating the table the content shows up.
`def PreviewCSV2(self):
fileName = self.Files.getCSV() # Get CSV-filename.
fileCsv = open(fileName, "r") # Open CSV as read-only.
readCsv = csv.reader(fileCsv) # Create readerobject.
amountrow = len(list(readCsv)) # Get count of rowsin csv.
self.PreviewTable.setRowCount(amountrow) # Set count of rows.
countrow = -1 # -1, because counter needs to be at 0 for the first row.
for row in readCsv: # Get single rows.
countrow += 1 # Increment rows.
countcol = 0 # Reset columns.
for field in row: # Get single fields.
item = QtWidgets.QTableWidgetItem() # Create new table content ...
item.setText(field) # Set text.
self.PreviewTable.setItem(countrow, countcol, item) # Set position, content.
countcol += 1 # Increment Columns.`
New contributor
MHF is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.