Nominate our 2022 Qt Champions!

passing c++ complex model to qml

  • I'm trying to figure out how to pass in a complex structure to qml. I'm using the data in it to populate the models of several qtquick elements.

    The top level object is a QList<QObject *> list with the objects having other QList<QObject *> inside. I've figured out how to get the top level list in to qml from the examples @ Using C++ Models with Qt Quick Views. My current problem is how do I get qml to process the QLists that point to other objects that are contained in the top level object?

    The top level object list is set as a property with a fromVariant() like this:

    ....setInitialProperties({{ "model", QVariant::fromValue(dataList) }});

    If I need to do something similar to the QLists inside the top level object, how do I do that?


Log in to reply