QTreeView - Add child (append rows) on expand
-
Hello,
I want to append the rows on expand. Meaning, I want to have the "+" sign enabled even if there are no rows present below. Because, I will be adding the rows on expand.
How to achieve this?
Thanks,
Kumar -
Hello,
I want to append the rows on expand. Meaning, I want to have the "+" sign enabled even if there are no rows present below. Because, I will be adding the rows on expand.
How to achieve this?
Thanks,
Kumar@kumararajas
override QAbstractItemModel::canFetchMore() and return true when there is data available for loading, false otherwise. -
@kumararajas
override QAbstractItemModel::canFetchMore() and return true when there is data available for loading, false otherwise.It is new to me. Thanks for the thought Raven.
But, still I am unable to get the expected results.I have overridden canFetchMore and return true always.
bool MyClass::canFetchMore(const QModelIndex & parent) const { return true; }
But, if I do not appendRow, then, I do not see the "expand" sign.
Since I dont see the "expand" sign, I am unable to load the items.
My goal is to load the items only on expand.
Any thoughts?
Thanks,
Kumara -
This is classic!
I was doing some silly mistakes. And I was too quick to reply back.
Later fixing my bugs, I could achieve it.
Thank you very much Raven!
--Kumara
-
This is classic!
I was doing some silly mistakes. And I was too quick to reply back.
Later fixing my bugs, I could achieve it.
Thank you very much Raven!
--Kumara
@kumararajas
and btw. what i forgot to mention:
you should load your data in the fetchMore() method of the model. IIRC this is called by the treeview on expand (when canFetchMore() returns true for this index). Maybe also in some other situations by Qt.
Anyway it's always a good idea to follow the given API. -
@kumararajas
and btw. what i forgot to mention:
you should load your data in the fetchMore() method of the model. IIRC this is called by the treeview on expand (when canFetchMore() returns true for this index). Maybe also in some other situations by Qt.
Anyway it's always a good idea to follow the given API.@raven-worx Thanks Raven! That helps me a lot..