title: how to store and retrieve custom data (using QtCore.Qt.UserRole?) with Qtableview /QAbstractTableModel in pyqt?
body: <p>I'm quite new in the use of model/view framework and I'm having some trouble,
  I'm using a Qtableview and a QAbstractTableModel on a widget and
  I'm trying to store some custom data in the QModelIndex using the "data" method from the QAbstractTableModel , something like this:</p>
  
  <pre><code>class myTableModel(QtCore.QAbstractTableModel):
  
  def __init__(self, parent = None):
      QtCore.QAbstractTableModel.__init__(self, parent)
      self.elements = [[this is supposed to be initialized at some point]] 
  
  def rowCount(self, parent = QtCore.QModelIndex()):
      return len(self.elements)
  
  def columnCount(self, parent = QtCore.QModelIndex()):
      return len(self.elements[0])
  
  def data(self, index, role = QtCore.Qt.DisplayRole):
      row = index.row()
      col = index.column()
      if role == QtCore.Qt.DisplayRole:
          return self.elements[row][col].getName()# an string gets stored and displayed on the widget
      if role == QtCore.Qt.UserRole: 
          return self.elements[row][col]
  </code></pre>
  
  <p>But I cannot make it to work:
  I've been able to retrieve successfully the name , but not the object . ..</p>
  
  <p>After some messing around including printing the "role" arg of the data method to see which roles are passed to the method ( I got 0,6,7,10 ... but not 32 or other roles ) and taking a look to the docs, it seems that only some roles ( not "QtCore.Qt.UserRole") are available during the call to "data" method?</p>
  
  <p>Is there a way of achieving this using "QtCore.Qt.UserRole"? I've read that this can be achieved using delegates? how exactly? and if not, how could I go about it?</p>
  
  <p>Thanks a lot!, 
  X</p>