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. Add dynamically new item in gridView
Forum Update on Monday, May 27th 2025

Add dynamically new item in gridView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 1.6k 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
    Salydan
    wrote on 16 Mar 2017, 08:30 last edited by
    #1

    Hi everyone,

    I would like to know if it's possible to add a new item in a gridView when the user click on a button for example. I see nothing about that on internet.

    On the screen below you can see my gridView. Currently I add items with the "listElement"
    Sample code grid View

    Thanks a lot

    Have a good day
    Simon

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 16 Mar 2017, 10:08 last edited by
      #2

      Since you are using the model view frame with GridView, Model and Delegate, just add new element to the model. Grid View will be updated automatically with new delegate. No extra effort!!!!

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      S 1 Reply Last reply 16 Mar 2017, 10:25
      2
      • D dheerendra
        16 Mar 2017, 10:08

        Since you are using the model view frame with GridView, Model and Delegate, just add new element to the model. Grid View will be updated automatically with new delegate. No extra effort!!!!

        S Offline
        S Offline
        Salydan
        wrote on 16 Mar 2017, 10:25 last edited by
        #3

        @dheerendra said in Add dynamically new item in gridView:

        Since you are using the model view frame with GridView, Model and Delegate, just add new element to the model. Grid View will be updated automatically with new delegate. No extra effort!!!!

        Can you show me sample code to add in my "button.onClicked" function to do this ?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 16 Mar 2017, 10:28 last edited by
          #4

          You can do something like follows in button.onClicked handler.

          gridView.model.insert(...) or gridView.model.append(..).

          See the ListModel documentation for the insert and/or append documentation. It should help you.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          S 1 Reply Last reply 16 Mar 2017, 10:35
          2
          • D dheerendra
            16 Mar 2017, 10:28

            You can do something like follows in button.onClicked handler.

            gridView.model.insert(...) or gridView.model.append(..).

            See the ListModel documentation for the insert and/or append documentation. It should help you.

            S Offline
            S Offline
            Salydan
            wrote on 16 Mar 2017, 10:35 last edited by
            #5

            @dheerendra said in Add dynamically new item in gridView:

            ListModel

            Thanks a lot !
            Its work perfectly :)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dheerendra
              Qt Champions 2022
              wrote on 16 Mar 2017, 10:42 last edited by
              #6

              Cool. Make the issue to "Solved". It helps others.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              2

              1/6

              16 Mar 2017, 08:30

              • Login

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