title: How to provide data from PySide QAbstractItemModel subclass to QML ListView?
body: <p>I have an app I'm writing in PySide that has a QML UI. I have subclassed QAbstractListModel in Python:</p>
  
  <pre><code>class MyModel(QtCore.QAbstractListModel):
      def __init__(self, parent=None):
          QtCore.QAbstractListModel.__init__(self, parent)
          self._things = ["foo", "bar", "baz"]
  
      def rowCount(self, parent=QtCore.QModelIndex()):
          return len(self._things)
  
      def data(self, index, role=QtCore.Qt.DisplayRole):
          if role == QtCore.Qt.DisplayRole:
              return self._things[index.row()]
          return None
  </code></pre>
  
  <p>I provide the model to my QML by doing this in the main script:</p>
  
  <pre><code>model = MyModel()
  view.rootContext().setContextProperty("mymodel", model)
  </code></pre>
  
  <p><a href="http://doc.qt.nokia.com/4.7/qdeclarativemodels.html" rel="nofollow">Qt's docs say</a> that the model's role names are used to access the data from QML, and that one can refer to the normal DisplayRole in QML as "display", therefore my QML has a ListView with a simple delegate like this:</p>
  
  <pre><code>ListView {
           anchors.fill: parent
           model: mymodel
           delegate: Component { Text { text: display } }
  }
  </code></pre>
  
  <p>However, when I do this the result is <code>file:///foo/bar/main.qml:28: ReferenceError: Can't find variable: display</code>.</p>
  
  <p>Setting custom role names in the model does not help. Ideas?</p>