diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-01-13 13:54:31 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-01-17 19:08:11 +0000 |
commit | ef60435d2f5bc1f3962388a3b51941015893a4d0 (patch) | |
tree | 2b3ae4b62e36e8ef586c02a3e49ab7f3fb917930 /src/widgets | |
parent | ec7e870e70bd83fbb22e5cf563fb7824f1a1fc44 (diff) |
QCommonStylePrivate::viewItemSize: fix text height calculation
QCommonStylePrivate::viewItemSize did not adjust the width when the item
had a decoration or a checkbox. This lead to a too big width used for
the layouting and therefore sometimes the calculated height was too
small.
Task-number: QTBUG-30116
Change-Id: I4468daa9820b9a8aa00fe959ab9b73fec23cc24e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtableview.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 1e6a60a4d7..ec25ccdb12 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -971,6 +971,9 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS option.rect.setHeight(height); option.rect.setX(q->columnViewportPosition(index.column())); option.rect.setWidth(q->columnWidth(index.column())); + // 1px less space when grid is shown (see drawCell) + if (showGrid) + option.rect.setWidth(option.rect.width() - 1); } hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height()); return hint; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 9f51a6b9d6..4a83cdd4a6 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -889,6 +889,13 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int break; } + if (wrapText) { + if (option->features & QStyleOptionViewItem::HasCheckIndicator) + bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin); + if (option->features & QStyleOptionViewItem::HasDecoration) + bounds.setWidth(bounds.width() - option->decorationSize.width() - 2 * textMargin); + } + const int lineWidth = bounds.width(); const QSizeF size = viewItemTextLayout(textLayout, lineWidth); return QSize(qCeil(size.width()) + 2 * textMargin, qCeil(size.height())); |