As per the below code, I need to create a model which will have N number of "System", and each "System" will have N number of "SytemDatabase" and each "SytemDatabase" will have N number of "CoresData". This N number will come to know during the launch time of application.
Qt Code:
  1. struct CoresData {
  2. int m_iCoreSpeed;
  3. bool m_bCoreAvailable;
  4. };
  5.  
  6. class SytemDatabase {
  7. public:
  8. SytemDatabase();
  9. bool m_bDatabaseVisible;
  10. int m_iDatabaseNumber;
  11. QList<CoresData> m_listCoresData;
  12. };
  13.  
  14. class Sytem {
  15. public:
  16. Sytem();
  17. bool m_bSystemAvailable;
  18. int m_iSystemNumber;
  19. QList<SytemDatabase> m_listSytemDatabase;
  20. };
  21.  
  22.  
  23.  
  24. class SytemTree : public QAbstractItemModel {
  25. Q_OBJECT
  26. public:
  27. explicit SytemTree( QObject *parent = nullptr);
  28. ~SytemTree();
  29. QVariant data(const QModelIndex &index, int role) const override;
  30. Qt::ItemFlags flags(const QModelIndex &index) const override;
  31. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
  32. QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
  33. QModelIndex parent(const QModelIndex &index) const override;
  34. int rowCount(const QModelIndex &parent = QModelIndex()) const override;
  35. int columnCount(const QModelIndex &parent = QModelIndex()) const override;
  36.  
  37. private:
  38. void addSytemDatabase(Sytem &data);
  39. QList<Sytem> m_listSystem;
  40. };
To copy to clipboard, switch view to plain text mode 

Currently I have designed this model using a ListModel and its working fine. Now for some reason i need to move this model to cpp side and pass that model to qml. Below is the QML code for just a reference

Qt Code:
  1. SytemTree.append({ "iSystemNumber": systemNumber, "bSystemAvailable": false, "SytemDatabase":[{ "iDatabaseNumber": databaseNumber, "bDatabaseVisible": false,"CoresData": []}]})
  2.  
  3. for( var lp = 0; lp < totalcoreData; ++lp) {
  4. SytemTree.get(systemNumber).SytemDatabase.get(iDatabaseNumber).CoresData.append({ "bCoreAvailable": true, "bCoreAvailable": true, "iCoreNumber": coreNumber})
  5. }
To copy to clipboard, switch view to plain text mode 

In qml side i want to use this model as like below
Qt Code:
  1. Repeater {
  2. id: repeaterRootSystem
  3. model: SytemTree
  4. delegate: Rectangle {--
  5. ----
  6. }
  7. Repeater {
  8. id: repeaterDatabase
  9. model: SytemTree.get(index).SytemDatabase
  10. delegate: Rectangle {---
  11. ---
  12. }
  13. Repeater {
  14. id: repeaterCoresData
  15. model: SytemTree.get(index).SytemDatabase.get(index).CoresData
  16. delegate: Rectangle {--
  17. ----
  18. }
To copy to clipboard, switch view to plain text mode 

I have gone through concepts QAbstractListModel, QAbstractItemModel and QAbstractTableModel. But am looking for a model like one list model, and each list element will contain a tree like structure as mentioned above in the classes. Requesting anyone to suggest how to create a model which will have tree like structure. and which QAbstractxxxxxmodel will be correct to implement this concept. and in QML side i want to access the data through the index untill coresData , same like above QML code.

Thanks in advance.