My issue is similar to PyQt - setText method of QTableWidget gets AttributeError. However, in this case the solution doesn't work.
I'm attempting to rewrite some fields automatically in which the values to be set are held in an array. As I have some empty rows I iterate over the rows to ensure that the name is relevant to the value that will be set.
#statsPlayer is a class that holds the array through a getter method
#modelTable is the QTableWidget
#possibilities is the array that holds the names of the rows that are to be modified
possiblities = ['Tackles', 'Blocks', 'Interceptions', 'Passes', 'Succesful Dribbles', 'Fouls Drawn', 'Goals', 'Assists', 'Penalties Scored']
counterTracker = 0
statsGroup = statsPlayer.statsGetter()[0]
for row in range(modelTable.rowCount()):
if modelTable.verticalHeaderItem(row).text() in possiblities:
modelTable.item(row, 0).setText(str(statsGroup[counterTracker]))
counterTracker += 1
My issue is after the first 3 rows (Tackles, Blocks and Interceptions), I receive an attribute error:
AttributeError: 'NoneType' object has no attribute 'setText'
The fields that I am attempting to modify are empty, so naturally they will be None. But why is it that I can edit the first 3 values but not the rest?