What is the "role" argument in QTableWidgetItem.data(self, int *role*)?
<p>I am looking through the documentation at:</p>

<ul>
<li><a href="http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidgetitem.html#data" rel="nofollow">http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidgetitem.html#data</a></li>
</ul>

<p>I can put the line <code>IDList.append(item.data())</code> into my code, and print that as the correct value. But weirdly, after that line, it gives me this error:</p>

<blockquote>
  <p>TypeError: QTableWidgetItem.data(int): not enough arguments</p>
</blockquote>

<p>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 <em>role</em>"? Can you give an example, please?</p>

<p>An item has many kinds of data associated with it, such as text, font, background, tooltip, etc. The <code>role</code> is a value from the <a href="https://doc.qt.io/qt-4.8/qt.html#ItemDataRole-enum" rel="nofollow">ItemDataRole enum</a> that allows you to specify which kind of data you want.</p>

<p>Some of these items of data also have an accessor function. So these two lines of code are equivalent:</p>

<pre><code>font = item.font()
font = item.data(QtCore.Qt.FontRole)
</code></pre>

<p>The data roles are extensible. You can use any values starting at <code>Qt.UserRole</code> to associate a custom role with your own data:</p>

<pre><code>MyRole = QtCore.Qt.UserRole + 2
item.setData(MyRole, [1, 2, 3])
...
data = item.data(MyRole)
</code></pre>

python pyqt qtablewidgetitem