diff options
Diffstat (limited to 'src/widgets/itemviews/qheaderview.cpp')
-rw-r--r-- | src/widgets/itemviews/qheaderview.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 9a8206de45..3396a91dc5 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1853,11 +1853,13 @@ bool QHeaderView::restoreState(const QByteArray &state) */ void QHeaderView::reset() { + Q_D(QHeaderView); QAbstractItemView::reset(); // it would be correct to call clear, but some apps rely // on the header keeping the sections, even after calling reset //d->clear(); initializeSections(); + d->invalidateCachedSizeHint(); } /*! @@ -2871,6 +2873,7 @@ bool QHeaderView::viewportEvent(QEvent *e) } return true; } #endif // QT_CONFIG(statustip) + case QEvent::Resize: case QEvent::FontChange: case QEvent::StyleChange: d->invalidateCachedSizeHint(); @@ -2965,8 +2968,10 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical margin += style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this) + style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); - if (d->textElideMode != Qt::ElideNone) - opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin); + if (d->textElideMode != Qt::ElideNone) { + const QRect textRect = style()->subElementRect(QStyle::SE_HeaderLabel, &opt, this); + opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode, textRect.width() - margin); + } QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation, Qt::ForegroundRole); @@ -3366,7 +3371,9 @@ void QHeaderViewPrivate::setupSectionIndicator(int section, int position) sectionIndicator->resize(w, h); #endif - QPixmap pm(w, h); + const qreal pixmapDevicePixelRatio = q->devicePixelRatioF(); + QPixmap pm(QSize(w, h) * pixmapDevicePixelRatio); + pm.setDevicePixelRatio(pixmapDevicePixelRatio); pm.fill(QColor(0, 0, 0, 45)); QRect rect(0, 0, w, h); @@ -3831,6 +3838,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) void QHeaderViewPrivate::setDefaultSectionSize(int size) { Q_Q(QHeaderView); + size = qBound(q->minimumSectionSize(), size, q->maximumSectionSize()); executePostedLayout(); invalidateCachedSizeHint(); defaultSectionSize = size; @@ -4086,7 +4094,7 @@ bool QHeaderViewPrivate::read(QDataStream &in) } int sectionItemsLengthTotal = 0; - foreach (const SectionItem §ion, newSectionItems) + for (const SectionItem §ion : qAsConst(newSectionItems)) sectionItemsLengthTotal += section.size; if (sectionItemsLengthTotal != lengthIn) return false; |