title: How can I retrieve data from database in QML?
body: <p>I am trying to retrieve data from database in QML. The code bellow works in Qt5 but I can't access the data from QML. I get: "undifined". Can anyone help me please?</p>
  
  <p>db.cpp</p>
  
  <pre><code>dataB = QSqlDatabase::addDatabase("QPSQL");
  
  dataB.setHostName("192...");
  dataB.setDatabaseName("database");
  dataB.setPort(123);
  
  dataB.setUserName("user1");
  dataB.setPassword("user1");
  
  this-&gt;model = new QSqlQueryModel();
  
  model-&gt;setQuery("SELECT status FROM telephone");
  
  ui-&gt;tableView-&gt;setModel(model);//result is in the first image
  
  QQuickView *view = new QQuickView();
  
  QQmlContext *context = view-&gt;rootContext();
  context-&gt;setContextProperty("mySQLmodel", model);
  
  view-&gt;setSource(QUrl("main.qml"));
  view-&gt;show();
  </code></pre>
  
  <p>main.qml</p>
  
  <pre><code>Rectangle {
  width: 300
  height: 300
  
  ListView {
      id: someListView
      anchors
      {
          fill: parent
   }
     model: mySQLmodel
      delegate: Label {
         text:{ "1 " + mySQLmodel.status}
     }
  
   }}
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/tG10D.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/AnhM2.png" alt="enter image description here"></p>