Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAbstractItemView batch update
Forum Updated to NodeBB v4.3 + New Features

QAbstractItemView batch update

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k Views 2 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.
  • P Offline
    P Offline
    poty
    wrote on last edited by
    #1

    Hi!

    I have a problem with updating QTreeView. (C++)

    I have a data tree which can be changed any time. My model receive events on data tree changes.
    If a new node is about to be added, the Model calls beginInsertRows with the proper parameters. After the data is added, my model calls endInsertRows.

    This works fine when only one new item is added(or a few under a common parent). In my case there are some big updates on the data tree with 10000+ new nodes added anywhere on the tree.
    Is it possible to handle all the new rows in a batch? If I call beginInsertRows for the whole model,(or beginmodelreset) 'expanded' states of the items are reseted which is not good.
    I have the same problem with deleting rows.

    VRoninV 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can, for example, divide the insertion in smaller blocks.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        poty
        wrote on last edited by
        #3

        Hi! Thanks for the answer!

        No, I cannot divide the insertion. My model receive one notification from the big underlying data change. The notification can contain all the info about the new elements. The model can call beginInsertRows and endInsertRows only once in this case.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you mean your underlying data are updated all at once ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P poty

            Hi!

            I have a problem with updating QTreeView. (C++)

            I have a data tree which can be changed any time. My model receive events on data tree changes.
            If a new node is about to be added, the Model calls beginInsertRows with the proper parameters. After the data is added, my model calls endInsertRows.

            This works fine when only one new item is added(or a few under a common parent). In my case there are some big updates on the data tree with 10000+ new nodes added anywhere on the tree.
            Is it possible to handle all the new rows in a batch? If I call beginInsertRows for the whole model,(or beginmodelreset) 'expanded' states of the items are reseted which is not good.
            I have the same problem with deleting rows.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @poty said in QAbstractItemView batch update:

            This works fine when only one new item is added(or a few under a common parent).

            Not really. the view updates only once the control has returned to the event loop so all your begin...() end...() will be processed by just 1 call to QAbstarctItemView::update()

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            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