Qt World Summit: Register Today!

Sharing QAbstractListModel based models (defined in C++)

  • I'm dynamically creating QML screens which have models defined in C++ and registered as context properties.

    This works fine until I create two screens which share a model. Both are live, one with opacity set to 0, so as to hide it. In this case I get an access violation after calls such as endResetModel().

    I think the cause is that two screens are tied to the same model and there is resource contention. Does anyone know how to handle this case?

  • What do you mean with "dynamically creating QML screens"? Do you have one application with multiple top level windows? Is there more than one processes working? Do you have multiple declarative views on a form? Do you run multiple qmlviewer?

  • i created a screen with Qt.createComponent and then saved a pointer to it in a container used as history. I would set the opacity to 0 when I created another screen. This was part of a Back Button feature but I scrapped the pointer approach and use a Loader.

    Since the loader deletes screens as it loads new ones there is no resource contention.

Log in to reply