I am using qmlRegisterUncreatableType() to register several C++ classes as QML types into a unique namespace. Each class comes with several properties.

Qt Code:
  1. class Battery : public QObject
  2. {
  3. Q_OBJECT
  4. Q_PROPERTY(QString voltageStr READ voltageStr NOTIFY changed)
  5. Q_PROPERTY(QString currentStr READ currentStr NOTIFY changed)
  6. public:
  7. // ...
  8. };
  9.  
  10. class Load : public QObject
  11. {
  12. Q_OBJECT
  13. Q_PROPERTY(QString voltageStr READ voltageStr NOTIFY changed)
  14. Q_PROPERTY(QString currentStr READ currentStr NOTIFY changed)
  15. Q_PROPERTY(QString activePowerStr READ activePowerStr NOTIFY changed)
  16. Q_PROPERTY(QString reactivePowerStr READ reactivePowerStr NOTIFY changed)
  17. public:
  18. // ...
  19. };
  20.  
  21. ...
  22.  
  23. qmlRegisterUncreatableType<Battery>("MyDevice", 1,0, "Battery", "");
  24. qmlRegisterUncreatableType<Battery>("MyDevice", 1,0, "Load", "");
To copy to clipboard, switch view to plain text mode 

On the QML side I would like to iterate through the types available in the MyDevice namespace and iterate through the properties made available in each class to display them for example in a tree view. The content of the TreeView should adapt automatically depending on how the amount of registered classes and properties in each class.

Has someone an idea how to iterate through the types available in a namespace and through the properties in a type available in a namespace in QML?

The result should be something like:

Qt Code:
  1. + MyDevice + Battery + Voltage + Value
  2. + Current + Value
  3. + Load + Voltage + Value
  4. + Current + Value
  5. + ActivePower + Value
  6. + ReactivePower + Value
To copy to clipboard, switch view to plain text mode