Hi everyone,

I'm quite new in Qt/QML so I still have to learn some basics. Here is my problem on my app.

My app has 2 ListView in qml, my model is "exported" from c++ by setContextProperty. The model is herited from QStandardItemModel and is called StandardQmlModel
My model is a 2 level model. Which means 1 "main" item can have children, and that's it.
So 1 Listview has the model exported from c++,once 1 item is selected from the first listview, the 2nd listview display the children items.

So, in c++ code I did this,

Qt Code:
  1. QObject* StandardQmlModel::childModel(QVariant child_item) const
  2. {
  3. QModelIndex idx = child_item.value<QModelIndex>();
  4.  
  5. QStandardItem* itm = 0;
  6. if(idx.isValid())
  7. {
  8. itm = (QStandardItem*)this->itemFromIndex(idx);
  9. if(itm->hasChildren())
  10. {
  11.  
  12. return itm->child(0,0).model();
  13. }
  14. }
  15. return 0;
  16. }
To copy to clipboard, switch view to plain text mode 

but what I get with this code is the "main" model, or the same model as display in the first ListView.
So my question is : How can I get the sub Model of an item in a view ?

Many thanks
Bounce