Search code examples
qtqmlqt5qtquick2qt-quick

How to export all the property/signal of qmlitem?


I have list of QML objects, I would like to populate properties/signals corresponding to each qml item, is there any API to get/parse all the properties of qmlitem?

Example:
qml: QQmlConnections(0xb719e0)
qml: QQmlTimer(0xb70c80)
qml: QQuickLoader(0xb3b780)
qml: QQuickLoader_QML_15(0xb262e0)
qml: QQuickItem(0xe3b3e0)
qml: QQuickLoader(0xe3b410)
qml: QQuickItem_QML_58(0xe41ba0)

Solution

  • You can iterate over an object's members like this:

    for (var p in obj) console.log(p + " " + typeof obj[p] + " " + obj[p])
    

    You can do even more from the C++ side, using QMetaObject as illustrated in this answer.