title: How do you access the roles of the currentItem from a listview in QML?
body: <p>I'm trying to access a role from a ListView in QML.  Essentially, I have this in my QML:</p>
  
  <pre><code>ListView {
      id: myId
      model: myModel
      delegate: Item {
          Text {
              text: model.text
          }
          Text {
              text: model.moreText
          }
      }
  }
  </code></pre>
  
  <p><code>myModel</code> is a QAbstractListModel implementation.  The QML portion of this is a reusable component, so the model could have any number of different roles with various data types.  What I would like to do is bind to the value of a given role of the <code>currentItem</code> property of the ListView.  In other words, I'd like to have some other <code>Component</code> on the page that could bind a property to the currently selected item in the ListView as follows:</p>
  
  <pre><code>Text {
      text: myId.currentItem.text // Or myId.currentItem.model.text (or something similar)
  }
  </code></pre>
  
  <p>Please keep in mind that I need this generically available, as I'll be doing this a lot for a number of model types and I'm trying not to write that kind of custom code for each model and ListView.</p>
  
  <p>It seems like it should be simple to access a property of the currently selected item, but as far as I can tell it is not possible.  The problem is complicated further by the fact that models appear to be treated differently when there is only one role.  By this I mean that sometimes you access your roles via <code>model.roleName</code> whereas when there is only one role you use <code>modelData</code>.</p>
  
  <p>If anybody has any suggestions, I would truly appreciate it.  Thanks so much!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I found this:</p>
  
  <p><a href="http://comments.gmane.org/gmane.comp.lib.qt.qml/1778">http://comments.gmane.org/gmane.comp.lib.qt.qml/1778</a></p>
  
  <p>However, this doesn't appear to work for me.  I'm getting type errors when I try to use the data in my QML scripts, and there is no type casting available so I'm not sure what to do.  Any suggestions are welcome!</p>
  
  <p>Thanks!</p>
  
  <p>Jack</p>