Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Non-static ListView model: how does QML Engine react?



  • Hello all,

    I am thinking my question is pretty self-explanatory, asking for a not-so-straightforward answer.

    • I am in the process of creating an app that involves a dynamic ListView, where the user is capable of adding, removing, or modifying Components by pressing on-screen buttons.

    • Each of these Components is capable of visualizing data from up to 5 sources. The user is also capable of removing a specified source, or adding another if the limit has not been reached.

    • As you might guess, each Source is constantly handling timeout() signals, appending a new data point to itself whenever this occurs.

    So my ListView is pretty dynamic.

    For this ListView, my model would by a context property C++ class that contains a QVector of lists. Each index of the QVector corresponds to a Component in the ListView, whereas the C++ list at each index of the QVector corresponds to the Sources for each Component. (If you need clarification here, let me know).

    What I am wondering is this: Let's say I use the length of the QVector as my ListView model. When a new list is appended to this QVector, OR let's say a new source is added to an existing list, does QML recognize this and act accordingly? Or rather, is this something I need to handle myself through signals/slots?

    My thinking would be that, because I am using an int as the ListView model, it would be able to detect a list being added or removed, but it would not be able to detect the addition or removal of a source from an existing list in the QVector. Is my thinking correct on this?

    Hopefully I didn't ramble. I tried to provide enough info to provide context, without going overboard.

    Thank you!



  • Hi @devDawg
    Why don't you just try it out as experiment? ^^



  • @Diracsbracket Great idea! I will re-post here when I have gotten to that point in my development, which should hopefully only take a day or two.


Log in to reply