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 refresh the appearance when the listmodel data has changed in a stackview ?
Forum Update on Monday, May 27th 2025

how to refresh the appearance when the listmodel data has changed in a stackview ?

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 5 Posters 2.3k 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.
  • hassonH Offline
    hassonH Offline
    hasson
    wrote on last edited by
    #1

    how to refresh the appearance when the listmodel data has changed in a stackview ? the page has pushed to a stackview, and the listmodel data is from c++ ,and how about refreshing a upper page ?
    thanks

    jsulmJ GrecKoG 2 Replies Last reply
    0
    • hassonH hasson

      how to refresh the appearance when the listmodel data has changed in a stackview ? the page has pushed to a stackview, and the listmodel data is from c++ ,and how about refreshing a upper page ?
      thanks

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @hasson That should be automatically the case when dataChanged() signal was emitted after changing data.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • hassonH Offline
        hassonH Offline
        hasson
        wrote on last edited by
        #3

        but what i saw is that the page didn't changed until re-push it

        J.HilkJ 1 Reply Last reply
        0
        • hassonH hasson

          but what i saw is that the page didn't changed until re-push it

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          @hasson
          by "re-pushing" you recreate your (List?)View, meaning it itself - without reacting to the signal - fetches the data from the c++ model.

          The fact that it only does this when recreated means there's either something wrong in the model binding (possibly broken) or your c++ model does not in fact emit the modelChanged signal.

          Impossible to tell, until you share some code with us


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • hassonH Offline
            hassonH Offline
            hasson
            wrote on last edited by
            #5

            thanks, my c++ model does not in fact emit the modelChanged signal

            S 1 Reply Last reply
            0
            • hassonH hasson

              thanks, my c++ model does not in fact emit the modelChanged signal

              S Offline
              S Offline
              sharath
              wrote on last edited by sharath
              #6

              Hi @hasson,

              you can try this.

              first emit one signal from your c++ class, lets say emit listmodelChanged() each time whenever your listmodel changes and in qml follow the code.

              StackView
              {
              id:stack
              }
              Connection
              {
              target:yourCppObject
                   onListmodelChanged:
                   {
                       stack.pop(null) 
                   }
              }
              
              1 Reply Last reply
              0
              • hassonH hasson

                how to refresh the appearance when the listmodel data has changed in a stackview ? the page has pushed to a stackview, and the listmodel data is from c++ ,and how about refreshing a upper page ?
                thanks

                GrecKoG Offline
                GrecKoG Offline
                GrecKo
                Qt Champions 2018
                wrote on last edited by
                #7

                @hasson said in how to refresh the appearance when the listmodel data has changed in a stackview ?:

                the listmodel data is from c++

                What do you mean by that?
                What is the type of your model and how do you update it in c++?

                hassonH 1 Reply Last reply
                0
                • hassonH Offline
                  hassonH Offline
                  hasson
                  wrote on last edited by
                  #8

                  @sharath thanks, but i don't want to pop any item when data changed

                  1 Reply Last reply
                  0
                  • GrecKoG GrecKo

                    @hasson said in how to refresh the appearance when the listmodel data has changed in a stackview ?:

                    the listmodel data is from c++

                    What do you mean by that?
                    What is the type of your model and how do you update it in c++?

                    hassonH Offline
                    hassonH Offline
                    hasson
                    wrote on last edited by
                    #9

                    Hi@grecko the model is inherit from QAbstractListModel, and i update it by writing data direct

                    1 Reply Last reply
                    0
                    • GrecKoG Offline
                      GrecKoG Offline
                      GrecKo
                      Qt Champions 2018
                      wrote on last edited by
                      #10

                      If you call the dataChanged signal and the [begin|end][Insert|Remove]Rows functions appropriately, it should work out of the box.

                      hassonH 1 Reply Last reply
                      1
                      • GrecKoG GrecKo

                        If you call the dataChanged signal and the [begin|end][Insert|Remove]Rows functions appropriately, it should work out of the box.

                        hassonH Offline
                        hassonH Offline
                        hasson
                        wrote on last edited by hasson
                        #11

                        @grecko said in how to refresh the appearance when the listmodel data has changed in a stackview ?:

                        it should work out of the box.

                        because of not using dataChanged signal,it doesn't work,,now it's working,
                        thank you!

                        1 Reply Last reply
                        0

                        • Login

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