Hi EveryOne,

I have a C++ class that does some operations
The method : getDataFromServer() exports some Data from server, it works well
Qt Code:
  1. for (int i = 0; i < projects.size(); ++i)
  2. {
  3. qDebug() << "result : " << projects[i];
  4. }
To copy to clipboard, switch view to plain text mode 

I want to display data in Listview QML

QML code
Qt Code:
  1. Rectangle
  2. {
  3. Component.onCompleted: {
  4. ClassTest.getDataFromServer();
  5. }
  6.  
  7. ClassTest{
  8. id: classTest
  9. }
  10.  
  11. Item {
  12. width: 800
  13. height: 600
  14.  
  15. ListView {
  16. id: listView
  17. anchors.left: parent.left
  18. anchors.top: parent.top
  19. anchors.bottom: parent.bottom
  20. width: 0.25 * parent.width
  21.  
  22. focus: true
  23. model: myModel
  24. delegate: Item {
  25.  
  26. width: parent.width
  27. height: 22
  28.  
  29. Text {
  30. anchors.centerIn: parent
  31. text: "data"
  32. }
  33.  
  34. MouseArea {
  35. anchors.fill: parent
  36. onClicked: {
  37. console.log(model.index)
  38. }
  39.  
  40. }
  41. }
  42. }
  43. }
To copy to clipboard, switch view to plain text mode 

getDataFromServer() code
Qt Code:
  1. ...
  2. // getData OK
  3. for (int i = 0; i < projects.size(); ++i)
  4. {
  5. qDebug() << "result : " << projects[i];
  6. }
  7. QQuickView *view= new QQuickView;
  8. QQmlContext *c = view->engine()->rootContext();
  9. c->setContextProperty("myModel", QVariant::fromValue(projects));
To copy to clipboard, switch view to plain text mode 

Any help plz

Cheers,