Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to make model's property not changing between states when loaded using loader?

    QML and Qt Quick
    qt quick qt for python model view prog
    2
    6
    85
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      satriyosan last edited by

      I have two distinct QAbstactListModel object exposed to QML , each tied to two distinct Repeater. When I switch views between two states, the model data on the second view was unintendedly copied from first view. I have tried to use standard role for accessing those data but still same. Are there any possibilities of clashing name when loading process happened? However, I made both modelname property distinct , and I print both object has difference memory locations. Help me guys.

      JoeCFD 1 Reply Last reply Reply Quote 0
      • JoeCFD
        JoeCFD @satriyosan last edited by

        @satriyosan you may check if you register the two models with the same name.

        S 1 Reply Last reply Reply Quote 0
        • S
          satriyosan @JoeCFD last edited by

          @JoeCFD I use setContextProperty method to register python object to qml. I've check that I use two different name when registering

          engine.rootContext().setContextProperty("channelmodel1", mymodel1)
          engine.rootContext().setContextProperty("channelmodel2", mymodel2)
          

          I created button to change both model data in one view, and everything was okay, each repeater changed it's own data. But only when I switch view then channelmodel2 data changed like mirrored to the channelmodel1 data.

          In the second view , when i pressed button , everything is okay, each repeater changed it's own data separately. The only problem is when the switching happen

          Btw I used states property of Rectangle to switch between loader item which consist each model.

          JoeCFD 1 Reply Last reply Reply Quote 0
          • JoeCFD
            JoeCFD @satriyosan last edited by

            @satriyosan You may show more code to let people help you.

            S 1 Reply Last reply Reply Quote 0
            • S
              satriyosan @JoeCFD last edited by satriyosan

              @JoeCFD Actually I created post about this but no one replied, so this link contain the code of the problem
              Uninteded modified model data

              1 Reply Last reply Reply Quote 0
              • S
                satriyosan last edited by

                I solved it. It turns out, I uses same listdata to both models, I need to make new listdata, and pass it to the second model. So models don't share same list data. problem solved.

                1 Reply Last reply Reply Quote 0
                • Topic has been marked as solved  S satriyosan 
                • First post
                  Last post