Qt Labs Forum » Declarative UI

Safely Loading and Deleting QML Views

(2 posts)
  • Started 2 months ago by ThomasM
  • Latest reply from Martin Jones

  1. ThomasM
    ThomasM
    Member

    Does anyone have any advice on how to dynamically load and delete entire QMLViews? I have a set of QML UI screens that I am trying to switch between but am not sure how to do so.

    I can't delete the current QMLView from the associated scripts attached to buttons or other UI elements because it is destroying the object hierarchy right out from under the script resulting in a crash, obviously.

    Do I need to have some sort of C++ thread running that accepts messages from the QML objects and scripts to queue up QMLView swaps? Or is there a simpler way to have the following work:

    UI_1.qml
    UI_2.qml

    Load UI_1.qml into a QMLView with a button that needs to trigger deleting UI_1.qml's view and load UI_2.qml to replace it.

    Posted: 2 months #
  2. The simplest would be to do this entirely in QML. For example:

    Loader { id: pageLoader; source: "UI_1.qml" }

    // UI_1.qml
    MouseRegion {
    onClicked: pageLoader.source = "UI_2.qml"
    }

    Make sure you're using an up to date version of QML (from git) as this crashes in older versions.

    Posted: 1 month #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.