Skip to content

Commit 4a91973

Browse files
chehrlicQt Cherry-pick Bot
authored andcommitted
Windows11Style: adjust sort indicator
Adjust the sort indicators for itemviews: - paint them above/below the text instead right of the label - the 'up' indicator is for ascending, 'down' for descending order on windows Pick-to: 6.8 Task-number: QTBUG-126345 Fixes: QTBUG-141895 Change-Id: Id649b5b36e5d1b84d68a7b05aebf2f53eddf9861 Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> (cherry picked from commit 92e22da) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 parent ccec2a9 commit 4a91973

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/plugins/styles/modernwindows/qwindows11style.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -858,15 +858,16 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
858858
break;
859859
case PE_IndicatorHeaderArrow:
860860
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
861-
QFont f(d->assetFont);
862-
f.setPointSize(6);
863-
painter->setFont(f);
864-
painter->setPen(header->palette.text().color());
865-
QRectF rect = option->rect;
866-
if (header->sortIndicator & QStyleOptionHeader::SortUp) {
867-
painter->drawText(rect, Qt::AlignCenter, ChevronUpSmall);
868-
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
869-
painter->drawText(rect, Qt::AlignCenter, ChevronDownSmall);
861+
const auto indicator = header->sortIndicator;
862+
if (indicator != QStyleOptionHeader::None) {
863+
QPainterStateGuard psg(painter);
864+
QFont f(d->assetFont);
865+
f.setPointSize(6);
866+
painter->setFont(f);
867+
painter->setPen(header->palette.text().color());
868+
painter->drawText(option->rect, Qt::AlignCenter,
869+
indicator == QStyleOptionHeader::SortUp ? ChevronDown
870+
: ChevronUp);
870871
}
871872
}
872873
break;
@@ -1935,7 +1936,7 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
19351936
#endif // QT_CONFIG(progressbar)
19361937
case QStyle::SE_HeaderLabel:
19371938
case QStyle::SE_HeaderArrow:
1938-
ret = QCommonStyle::subElementRect(element, option, widget);
1939+
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
19391940
break;
19401941
case SE_PushButtonContents: {
19411942
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);

0 commit comments

Comments
 (0)