QTreeView expand/collapse indicator disappears
-
Hi,
I set the following stylesheet for the QTreeView:
QTreeView::branch:has-children:!has-siblings:closed, QTreeView::branch:closed:has-children:has-siblings { image: url(:/Images/tree-collapsed); } QTreeView::branch:open:has-children:!has-siblings, QTreeView::branch:open:has-children:has-siblings { image: url(:/Images/tree-expanded); }
Scenario:
Root
--|-B
---- |+C
---- |_ -D- Expand until a branch, D. The D branch is unable to get it's children, now collapse the parent branch, B.
- When we expand parent B again, the D branch does not have the expand/collapse button.
I need the button to stay with the branches always.
Why is the button being removed and how to retain the expand/collapse indicator?Thanks.
-
Hi,
Why is the branch D unable to get its children ?
What version of Qt ?
What platform ? -
Then it make sense that it can't show anything since it can't retrieve any information.
-
@SGaist said in QTreeView expand/collapse indicator disappears:
hat it can't show anything since it can't retrieve any information
Right. But i would like the expand/collapse to remain.
In case the other system comes up, i can't expand this branch anymore since the indicator is not there.I would need to go to a different view and come back for it to display the indicator again.
-
Then you have to provide a "fake" model entry that represents the data that should arrive.
-
What kind of other solution do you have in mind ? If your model doesn't have the data for some reason, either you provide a mean to tell the user that the data is coming and trigger an update when it's really there or you don't show anything until the data has arrived and then trigger an update of the view.
-
@vdevadass
a treeview shows an expand indicator when the model'srowCount()
method returns a value > 0 or if it'scanFetchMore()
method returns true.
So delayed loading should be implemented via thecanFetchMore()
andfetchMore()
methods of the model. -
@raven-worx from my understanding, the data was already there or at least part of it available at some point. I'm not sure that
canFetchMore()
andfetchMore()
would be of use in this case. But they sure would be when starting to load the data. -
@SGaist said in QTreeView expand/collapse indicator disappears:
from my understanding, the data was already there or at least part of it available at some point.
i understood that differently, due to the following comments:
Expand until a branch, D. The D branch is unable to get it's children, now collapse the parent branch, B.
The branch children are being requested from another system on the network.
Hence, if the system is not up, we are unable to get the list of children. -
@vdevadass said in QTreeView expand/collapse indicator disappears:
l
QTreeView::branch:closed:adjoins-item:has-children {
image: url(:/Images/tree-collapsed);
}QTreeView::branch:open:adjoins-item {
image: url(:/Images/tree-expanded);
}