QAbstractItemView batch update
-
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. -
Hi,
You can, for example, divide the insertion in smaller blocks.
-
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.
-
Do you mean your underlying data are updated all at once ?
-
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.@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 toQAbstarctItemView::update()