diff options
| author | Doris Verria <doris.verria@qt.io> | 2026-09-01 10:52:18 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2026-09-02 14:04:47 +0000 |
| commit | cd2ed17d962046fd2e9b7e9fc57f9cbca0d64bd0 (patch) | |
| tree | edf388ae403179a04cecabd98915edd84dc83f67 | |
| parent | fb82d6f67e0f2352ca7507b02f4ea03d4b4c364d (diff) | |
QStyleKitStyle: Fix setting correct type and state on readers
- When first creating the reader for the widget, set the correct type
so that during the draw call we don't unecessarily trigger a type change
from Unspecified to whatever the right control type is.
- Don't always set the Vertical state flag if the widget's QStyleOption
doesn't have the Horizontal state set. This makes sense only for widgets
which have orientation and actually use the Horizontal state.
Change-Id: I9c0d62b79c277f730280ae6d380abb008a47d0fa
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit adef93975afe4d4f15d86ae44174be58f08395f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| -rw-r--r-- | src/labs/stylekit/widgets/qstylekitstyle.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/labs/stylekit/widgets/qstylekitstyle.cpp b/src/labs/stylekit/widgets/qstylekitstyle.cpp index da428bec63..246c809bdb 100644 --- a/src/labs/stylekit/widgets/qstylekitstyle.cpp +++ b/src/labs/stylekit/widgets/qstylekitstyle.cpp @@ -871,6 +871,7 @@ QQStyleKitReader *QStyleKitStylePrivate::readerForWidget(const QWidget *widget) auto *widgetReader = new QQStyleKitReader(const_cast<QStyleKitStyle *>(q)); widgetReader->setExplicitStyle(effective); widgetReader->setTarget(paintTarget(widget)); + widgetReader->setControlType(controlTypeForWidget(widget)); widgetReader->setCompleted(true); widgetReaders.insert(widget, widgetReader); QObjectPrivate::connect(widget, &QObject::destroyed, this, @@ -1045,7 +1046,22 @@ QQSK::State QStyleKitStylePrivate::resolvedStateFor(QQStyleKitReader::ControlTyp flags.setFlag(QQSK::StateFlag::Checked, state & QStyle::State_On); flags.setFlag(QQSK::StateFlag::Focused, state & QStyle::State_HasFocus); flags.setFlag(QQSK::StateFlag::Highlighted, state & QStyle::State_Selected); - flags.setFlag(QQSK::StateFlag::Vertical, !(state & QStyle::State_Horizontal)); + + bool hasOrientation = false; + switch (type) { + case QQStyleKitReader::ProgressBar: + case QQStyleKitReader::ScrollBar: + case QQStyleKitReader::ScrollIndicator: + case QQStyleKitReader::Slider: + case QQStyleKitReader::ToolBar: + case QQStyleKitReader::ToolSeparator: + hasOrientation = true; + break; + default: + break; + } + if (hasOrientation) + flags.setFlag(QQSK::StateFlag::Vertical, !(state & QStyle::State_Horizontal)); // Some widgets don't set State_Enabled in their // style option even when the widget is enabled. // Fall back to widget->isEnabled() in that case |
