QTreeView with valid setAutoExpandDelay to Only do expand, and never do collapse for already expanded items.
-
Hi everyone,
I have a class that extends QTreeView and I have enabled the auto expand functionality via the mouse Hover,
by setting the autoExpandDelay(500);
This works to have the folders auto-expand as expected, However it also does the reverse to an already expanded dir.
ie. it collapses that dir.Ideally I would like to make it so that the autoExpand function never triggers a collapse();
Is this possible?I have tried to extend the expand() and collapse() slots, but they are not virtual in the QTreeView base class :(
My only other option is not to enable the autoExapnd functionality and try and provide that myself,
but I am not too confident about doing that - especially in a performant manner.Cheers,
James
-
Hi,
AFAIK, no it's not, the animated property documentation explicitly says it applies to both. The implementation of QTreeView confirms this. It happens in the private implementation of the class.
-
I've managed to hack together my own solution,
(based on looking at the source )Using my own QBasicTimer, and overriding the
void timerEvent(QTimerEvent *event) and
void dragMoveEvent(QDragMoveEvent *event)it's a bit ugly but it works.
it would be nice if the default mechanism offered the option to make the time expand only.Cheers,
-
@SGaist I don't see the relation with the animated property, which is about an animation on expand/collapse (including when the user manually clicks on an item). autoExpandDelay() is about drag-n-drop only. This discussion is basically https://bugreports.qt.io/browse/QTBUG-2553
-
I may have misread the code back then but nice that you are taking care of it.