The trick is that double-clicking also increases one click by default. Before deploying the default animation, call QAbstractItemView::setState(AnimatingState) to set the internal state for the animation.
And in QAbstractItemView::mouseReleaseEvent() , QAbstractItemView::setState(NoState) is called before the animation finishes. After that, the animation stops immediately.
Use the following code to work:
void YourSubTreeView::mouseReleaseEvent(QMouseEvent* event) { QAbstractItemView::State preState = state(); QTreeView::mouseReleaseEvent(event); if (preState == QAbstractItemView::AnimatingState) setState(preState); }
source share