title: QML how to create different types based on a condition
body: <p>I was wondering what's the best way to create a Rectangle, Text or Button based on a condition inside my QML code.</p>
  
  <p>Here's a pseudo code:</p>
  
  <pre><code>    import QtQuick 2.0
  
      Item{
          property string name = "rect" or "text" or "button"
          id:root
  
          if (name === "rect")
          Rectangle {
              //properties
              parent: root
          }
  
          else if (name === "text")
          Text {
              //properties
              parent: root
          }
  
          else if (name === "button")
          Button {
              //properties
              parent: root
          }
      }
  </code></pre>