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

How to refresh listview in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 3 Posters 14.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.
  • J Offline
    J Offline
    jiji
    wrote on last edited by
    #1

    Hi,
    How can I refresh a listview in QML when I add a new entity ??!!
    Please help me.

    ibiaI 1 Reply Last reply
    0
    • J jiji

      Hi,
      How can I refresh a listview in QML when I add a new entity ??!!
      Please help me.

      ibiaI Offline
      ibiaI Offline
      ibia
      wrote on last edited by ibia
      #2

      Hello! Please, use the forceLayout function. This method forces the ListView to immediately respond to any outstanding changes in the model (documentation).

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jiji
        wrote on last edited by
        #3

        How can I use it !!!

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Why do you think you need to refresh the view? It should automatically get updated on model changes.

          1 Reply Last reply
          0
          • ibiaI Offline
            ibiaI Offline
            ibia
            wrote on last edited by
            #5

            Call the function forceLayout on your ListView, after updating the model.

            1 Reply Last reply
            -1
            • ibiaI Offline
              ibiaI Offline
              ibia
              wrote on last edited by
              #6

              The documentation tells that :

              Responding to changes in the model is usually batched to happen only once per frame. This means that inside script blocks it is possible for the underlying model to have changed, but the ListView has not caught up yet.

              So this method forces the ListView to immediately respond to any outstanding changes in the model.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jiji
                wrote on last edited by jiji
                #7

                @Wieland It get updated when I run the application one more time, but I want refresh it when I add a new entity in my data base without close and run the application every time.

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  jiji
                  wrote on last edited by
                  #8

                  @ibia thank you, I will try it and I hope it works

                  1 Reply Last reply
                  0
                  • ibiaI Offline
                    ibiaI Offline
                    ibia
                    wrote on last edited by
                    #9

                    You're welcome! I hope it helped.

                    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