QAIV::sizeHintForIndex: return correct size when no delegate is set

QAIV::sizeHintForIndex checks if a delegate is set for this view but
does not check if there are row/column delegates which may be
appropriate for this task.
Fix it by retrieving the correct delegate directly with
delegateForIndex().

Change-Id: I264359b12e1983aab3a917db7dbcab11253a448f
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Christian Ehrlicher 2019-12-06 21:03:54 +01:00
parent 4c3c63d4cb
commit 9608e996a2

View File

@ -3074,9 +3074,10 @@ void QAbstractItemView::keyboardSearch(const QString &search)
QSize QAbstractItemView::sizeHintForIndex(const QModelIndex &index) const
{
Q_D(const QAbstractItemView);
if (!d->isIndexValid(index) || !d->itemDelegate)
if (!d->isIndexValid(index))
return QSize();
return d->delegateForIndex(index)->sizeHint(d->viewOptionsV1(), index);
const auto delegate = d->delegateForIndex(index);
return delegate ? delegate->sizeHint(d->viewOptionsV1(), index) : QSize();
}
/*!