Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to make model's property not changing between states when loaded using loader?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qt quickqt for pythonmodel view prog
6 Posts 2 Posters 581 Views
  • 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 Offline
    S Offline
    satriyosan
    wrote on last edited by
    #1

    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.

    JoeCFDJ 1 Reply Last reply
    0
    • S satriyosan

      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.

      JoeCFDJ Online
      JoeCFDJ Online
      JoeCFD
      wrote on last edited by
      #2

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

      S 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

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

        S Offline
        S Offline
        satriyosan
        wrote on last edited by
        #3

        @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.

        JoeCFDJ 1 Reply Last reply
        0
        • S satriyosan

          @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.

          JoeCFDJ Online
          JoeCFDJ Online
          JoeCFD
          wrote on last edited by
          #4

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

          S 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

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

            S Offline
            S Offline
            satriyosan
            wrote on last edited by satriyosan
            #5

            @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
            0
            • S Offline
              S Offline
              satriyosan
              wrote on last edited by
              #6

              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
              0
              • S satriyosan has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved