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 Updated to NodeBB v4.3 + New Features

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.
  • H Offline
    H Offline
    hasson
    wrote on 8 Aug 2019, 07:54 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

    J G 2 Replies Last reply 8 Aug 2019, 07:59
    0
    • H hasson
      8 Aug 2019, 07:54

      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

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 8 Aug 2019, 07:59 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
      • H Offline
        H Offline
        hasson
        wrote on 8 Aug 2019, 08:07 last edited by
        #3

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

        J 1 Reply Last reply 8 Aug 2019, 08:20
        0
        • H hasson
          8 Aug 2019, 08:07

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

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 8 Aug 2019, 08:20 last edited by J.Hilk 8 Aug 2019, 08:21
          #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
          • H Offline
            H Offline
            hasson
            wrote on 8 Aug 2019, 09:12 last edited by
            #5

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

            S 1 Reply Last reply 8 Aug 2019, 10:32
            0
            • H hasson
              8 Aug 2019, 09:12

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

              S Offline
              S Offline
              sharath
              wrote on 8 Aug 2019, 10:32 last edited by sharath 8 Aug 2019, 10:34
              #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
              • H hasson
                8 Aug 2019, 07:54

                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

                G Offline
                G Offline
                GrecKo
                Qt Champions 2018
                wrote on 8 Aug 2019, 12:33 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++?

                H 1 Reply Last reply 9 Aug 2019, 06:00
                0
                • H Offline
                  H Offline
                  hasson
                  wrote on 9 Aug 2019, 05:11 last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • G GrecKo
                    8 Aug 2019, 12:33

                    @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++?

                    H Offline
                    H Offline
                    hasson
                    wrote on 9 Aug 2019, 06:00 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
                    • G Offline
                      G Offline
                      GrecKo
                      Qt Champions 2018
                      wrote on 9 Aug 2019, 07:30 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.

                      H 1 Reply Last reply 9 Aug 2019, 07:51
                      1
                      • G GrecKo
                        9 Aug 2019, 07:30

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

                        H Offline
                        H Offline
                        hasson
                        wrote on 9 Aug 2019, 07:51 last edited by hasson 8 Sept 2019, 08:05
                        #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

                        1/11

                        8 Aug 2019, 07:54

                        • Login

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