From 35ebdeb83eb4057f5e50042747b13d0772051459 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 16 Oct 2014 13:38:11 +0200 Subject: [PATCH] QTreeView: Fix expanding of spanning items When using HeaderView::ResizeToContents and QTreeWidgetItem::setFirstColumnSpanned(), it happens that the position of the branch icon is no longer in the first column and thus trying to expand the item results in a selection change. Check for spanning when determining the position. Task-number: QTBUG-41793 Change-Id: I14353127436fb0ebaafb0d50a31b920b8da67333 Reviewed-by: Christian Ehrlicher Reviewed-by: David Faure --- src/widgets/itemviews/qtreeview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index b339fe0f3b..b534de5c6a 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3724,9 +3724,14 @@ void QTreeViewPrivate::updateScrollBars() int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const { + Q_Q(const QTreeView); executePostedLayout(); - int x = pos.x(); - int column = header->logicalIndexAt(x); + bool spanned = false; + if (!spanningIndexes.isEmpty()) { + const QModelIndex index = q->indexAt(pos); + spanned = q->isFirstColumnSpanned(index.row(), index.parent()); + } + const int column = spanned ? 0 : header->logicalIndexAt(pos.x()); if (!isTreePosition(column)) return -1; // no logical index at x