title: How to access data stored in QModelIndex
body: <p>The code below create a single <code>QListView</code> with the data and proxy models "attached".
  Clicking one of the radio buttons calls for <code>buttonClicked()</code> function. </p>
  
  <p>This function calls model's <code>.data(index,role)</code> method to get the data stored in a current index. </p>
  
  <p>For the <code>DisplayRole</code> the model's <code>.data()</code> method properly returns the name of index (assigned to it by the time it was created). But when<br>
  'ItemDataRole' is used I am getting an error:</p>
  
  <pre><code>TypeError: QSortFilterProxyModel.data(QModelIndex, int role=Qt.DisplayRole): argument 2 has unexpected type 'sip.enumtype'
  </code></pre>
  
  <p>--</p>
  
  <pre><code>Question 1: How to fix this error?
  </code></pre>
  
  <p>If you take a look at <code>addItems()</code> method there is a line there:</p>
  
  <pre><code>self.setData(index, 'keyword')
  </code></pre>
  
  <p>Apparently I am trying to set 'keyword' as my own "custom data" (is it what ProxyModel is going to be use while filtering the indexes?). </p>
  
  <p>Question 2: How to query the string "keyword" I've set with <code>self.setData(index, 'keyword')</code>?
  Is this data accessible or it is "reserved" and can't be queried?</p>
  
  <p><img src="https://i.stack.imgur.com/HX0ZG.png" alt="enter image description here"></p>
  
  <pre><code>from PyQt4 import QtCore, QtGui
  app=QtGui.QApplication(sys.argv)
  elements={'Animals':{1:'Bison',2:'Panther',3:'Elephant'},'Birds':{1:'Duck',2:'Hawk',3:'Pigeon'},'Fish':{1:'Shark',2:'Salmon',3:'Piranha'}}
  
  class ProxyModel(QtGui.QSortFilterProxyModel):
      def __init__(self, parent=None):
          super(ProxyModel, self).__init__(parent)
  
  class DataModel(QtCore.QAbstractListModel):
      def __init__(self):
          QtCore.QAbstractListModel.__init__(self)
          self.items=[] 
      def rowCount(self, parent=QtCore.QModelIndex()):
          return len(self.items)
      def data(self, index, role):
          if not index.isValid() or not (0&lt;=index.row()&lt;len(self.items)):  return QtCore.QVariant()
  
          if role==QtCore.Qt.DisplayRole:
              return self.items[index.row()]
  
          elif role==QtCore.Qt.ItemDataRole:
              return index.data()
  
      def addItems(self):
          for key in elements:
              index=QtCore.QModelIndex()
              self.setData(index, 'keyword')
              self.beginInsertRows(index, 0, 0)
              self.items.append(key)           
  
          self.endInsertRows()        
  
  class Window(QtGui.QWidget):
      def __init__(self):
          super(Window, self).__init__()
          layout=QtGui.QVBoxLayout()
          self.setLayout(layout)        
  
          self.view=QtGui.QListView()
  
          self.dataModel=DataModel()        
          self.dataModel.addItems()
  
          self.proxyModel=ProxyModel()
          self.proxyModel.setSourceModel(self.dataModel)
          self.view.setModel(self.proxyModel)
          buttonsLayout=QtGui.QHBoxLayout()
          animalsButton=QtGui.QRadioButton('Show Animals')
          birdsButton=QtGui.QRadioButton('Show Birds')
          fishButton=QtGui.QRadioButton('Show Fish')
          self.buttons=[animalsButton,birdsButton,fishButton]
          for button in self.buttons:
              button.toggled.connect(self.buttonClicked)
              buttonsLayout.addWidget(button)      
          layout.addWidget(self.view)
          layout.insertLayout(1,buttonsLayout)
          self.show()
  
      def buttonClicked(self,arg=None):
          for button in self.buttons:
              if button.isChecked(): break
  
          index=self.view.currentIndex()
          print 'Index DisplayRole: %s'%self.view.model().data(index, QtCore.Qt.DisplayRole).toString() 
          # print 'ItemDataRole', self.view.model().data(index, QtCore.Qt.ItemDataRole)    
  
  window=Window()
  sys.exit(app.exec_())
  </code></pre>