title: Different delegates for QML ListView
body: <p>I would like to know if it's possible to use (several) different delegates for a QML <code>ListView</code>. </p>
  
  <p>Depending on the individual object in the <code>ListView</code> model, I would like to visualize the objects with different delegates.</p>
  
  <p>This piece of code explains what I want to achieve: </p>
  
  <p><strong>main.qml</strong></p>
  
  <pre><code>import QtQuick 2.4
  import QtQuick.Controls 1.3
  import QtQuick.Window 2.2
  import QtQuick.Dialogs 1.2
  
  ApplicationWindow {
      title: qsTr("Hello World")
      width: 640
      height: 480
      visible: true
  
      ListModel {
          id: contactsModel
          ListElement {
              name: "Bill Smith"
              position: "Engineer"
          }
          ListElement {
              name: "John Brown"
              position: "Engineer"
          }
          ListElement {
              name: "Sam Wise"
              position: "Manager"
          }
      }
  
      ListView {
          id: contactsView
          anchors.left: parent.left
          anchors.top: parent.top
          width: parent.width
          height: parent.height
          orientation: Qt.Vertical
          spacing: 10
          model: contactsModel
          delegate: {
              if (position == "Engineer") return Employee;  //&lt;--- depending on condition, load Contact{}
              else if (position == "Manager") return Manager; //&lt;--- depending on condition, load Person{}
          }
      }
  }
  </code></pre>
  
  <p><strong>Employee.qml</strong> (One possible Component which I would like to use as a delegate)</p>
  
  <pre><code>import QtQuick 2.4
  
  Rectangle{
      width: 200
      height: 50
      color: ListView.isCurrentItem ? "#003366" : "#585858"
      border.color: "gray"
      border.width: 1
  
      Text{
          anchors.centerIn: parent
          color: "white"
          text: name
      }
  }
  </code></pre>
  
  <p><strong>Manager.qml</strong> (other Component I would like to use as a delegate)</p>
  
  <pre><code>import QtQuick 2.4
  
  Rectangle{
      width: 200
      height: 50
      color: "red"
      border.color: "blue"
      border.width: 1
  
      Text{
          anchors.centerIn: parent
          color: "white"
          text: name
      }
  }
  </code></pre>
  
  <p>I would appreciate any advice!
  Thanks!</p>