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. [SOLVED]How to control refreshing qml view?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]How to control refreshing qml view?

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 2 Posters 2.3k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    av2306
    wrote on last edited by
    #1

    Hi,

    QML View with C++ Model. QAbstractListModel for c++ model and ListView on QML View with delegates.

    When I launch view, CPU goes very high. I am suspecting QAbstractListModel::data called for every few milliseconds. How to control this? Any other inputs to control cpu?

    Thanks.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      It should not happen. Are you doing any heavy processing in it ?
      QAbstractListModel::data will be called only when needed from the delegate. And on the first launch by default it should not even load all the items unless requested.

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        av2306
        wrote on last edited by
        #3

        No heavy processing.

        On What basis, delegate requests data from model?

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Whenever delegates are instantiated.

          157

          1 Reply Last reply
          0
          • A Offline
            A Offline
            av2306
            wrote on last edited by
            #5

            There is an animation control in view item. Delegate updates the animation by using model data in delegate. And, items are getting added and deleted based on animation status. Should I destroy items manually? Any inputs.

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              Does the ListView load all of the Items initially ?

              157

              1 Reply Last reply
              0
              • A Offline
                A Offline
                av2306
                wrote on last edited by
                #7

                It's empty initially. C++ model fetches data from server and inform to AbstractListModel through signals (Add, update, del). Whenever any changes on model, it reflects immediately on view. Any inputs?

                1 Reply Last reply
                0
                • p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #8

                  bq. C++ model fetches data from server

                  Have you made sure that this operation is not doing any CPU intensive work ?

                  157

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    av2306
                    wrote on last edited by
                    #9

                    Verified with QML View and without QML View. When I launched ui, then only I can see cpu high. Otherwise, it's very normal. Added logs in AbstractListModel overridden functions. Model emit signal for every change. But, "data" fired many times. So, I suspected on "data" calling from qml.

                    1 Reply Last reply
                    0
                    • p3c0P Offline
                      p3c0P Offline
                      p3c0
                      Moderators
                      wrote on last edited by
                      #10

                      May be somewhere the List is getting refilled again on each added Item. Can you post the code ?

                      157

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        av2306
                        wrote on last edited by
                        #11

                        Thank you for your inputs. My TCP Server sends 100+ events to client in a second. Controlled the signals passing to view. Now, cpu normal. Thank you again.

                        1 Reply Last reply
                        0
                        • p3c0P Offline
                          p3c0P Offline
                          p3c0
                          Moderators
                          wrote on last edited by
                          #12

                          Ok. You're Welcome :)
                          Please mark the post as solved.

                          157

                          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