From 877b29a78e38ff7c6af2d63d93e6a554544bf278 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Wed, 23 Oct 2024 15:26:15 +0200 Subject: [PATCH] QWindows11Style: Add checkbox offset to ItemViewItemText Add the width of a checkbox to the starting starting x position of the ItemViewItemText in case the ItemViewItem has a checkbox. Fixes: PYSIDE-2897 Fixes: PYSIDE-2906 Pick-to: 6.8 Change-Id: I233e2bfd28836ae5578aadfe9332193848ac5a7f Reviewed-by: Friedemann Kleint Reviewed-by: Axel Spoerl --- src/plugins/styles/modernwindows/qwindows11style.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index a0afd690946..6e36d0f0f2e 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -1784,9 +1784,13 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp case QStyle::SE_ItemViewItemText: if (const auto *item = qstyleoption_cast(option)) { const int decorationOffset = item->features.testFlag(QStyleOptionViewItem::HasDecoration) ? item->decorationSize.width() : 0; + const int checkboxOffset = item->features.testFlag(QStyleOptionViewItem::HasCheckIndicator) ? 16 : 0; if (widget && widget->parentWidget() && widget->parentWidget()->inherits("QComboBoxPrivateContainer")) { - ret = option->rect.adjusted(decorationOffset + 5, 0, -5, 0); + if (option->direction == Qt::LeftToRight) + ret = option->rect.adjusted(decorationOffset + checkboxOffset + 5, 0, -5, 0); + else + ret = option->rect.adjusted(5, 0, decorationOffset - checkboxOffset - 5, 0); } else { ret = QWindowsVistaStyle::subElementRect(element, option, widget); }