I am looking through the documentation at:
I can put the line IDList.append(item.data())
into my code, and print that as the correct value. But weirdly, after that line, it gives me this error:
TypeError: QTableWidgetItem.data(int): not enough arguments
I don't know why the error message comes after the print line, but I don't think that should be important. What does the documentation mean by "int role"? Can you give an example, please?
An item has many kinds of data associated with it, such as text, font, background, tooltip, etc. The role
is a value from the ItemDataRole enum that allows you to specify which kind of data you want.
Some of these items of data also have an accessor function. So these two lines of code are equivalent:
font = item.font()
font = item.data(QtCore.Qt.FontRole)
The data roles are extensible. You can use any values starting at Qt.UserRole
to associate a custom role with your own data:
MyRole = QtCore.Qt.UserRole + 2
item.setData(MyRole, [1, 2, 3])
...
data = item.data(MyRole)