diff options
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index dd430435f3..781dd345bd 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -754,6 +754,8 @@ void QTreeView::expand(const QModelIndex &index) return; if (index.flags() & Qt::ItemNeverHasChildren) return; + if (d->isIndexExpanded(index)) + return; if (d->delayedPendingLayout) { //A complete relayout is going to be performed, just store the expanded index, no need to layout. if (d->storeExpanded(index)) @@ -785,6 +787,8 @@ void QTreeView::collapse(const QModelIndex &index) Q_D(QTreeView); if (!d->isIndexValid(index)) return; + if (!d->isIndexExpanded(index)) + return; //if the current item is now invisible, the autoscroll will expand the tree to see it, so disable the autoscroll d->delayedAutoScroll.stop(); |