PDA

View Full Version : Not allow expander Icon to expand items in QTreeview



chithara
20th May 2019, 08:51
Hi,

I have a QTreeView with read-only custom model derived from QAbstractItemModel. On Double-clicking the TreeItem, I am calling setExpanded(index,false) in order to wait till the parent node gets populated and calling setExpanded(index,true) once all the data is arrived.

The above scenario works perfectly.But when I try to click the expander/collapsible icon (while the expanded state of the tree item state is still false), the parent node expands and shows the child nodes irrespective of the state.

I want to disable this icon (or) try to get a signal on this icon click so that my tree-view will expand only after all the data population done.

Please help on this as this is affecting my UI performance in case of huge data

anda_skoa
20th May 2019, 13:07
Hmm.

The model could not tell the view that it already has children for a particular model index until it has all of them.

Or it could return just a single "dummy" entry that says something like "loading...", or even an indication of progress.

So while you are fetching data your model's internal data structure would get updated but the model would "remember" that this is currently "internal".

Cheers,
_