From 99a417240d6bd8361446e148ea25071d04867e12 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Thu, 23 Oct 2025 15:38:53 +0800 Subject: [PATCH] fix: recalculate state on scrollbar policy change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed an issue where scrollbar visibility states were not properly updated when the scroll policy changed. Added a handler for the policyChanged signal to trigger state condition recalculation, ensuring the scrollbar appears/disappears correctly according to policy settings. Influence: 1. Test scrollbar visibility when changing between ScrollBar.AsNeeded, ScrollBar.AlwaysOn, and ScrollBar.AlwaysOff policies 2. Verify scrollbar appears and disappears correctly based on content size and policy settings 3. Check that scrollbar state transitions smoothly when policy changes dynamically 4. Test with different scrollbar orientations (vertical/horizontal) fix: 修复滚动条策略变更时状态未更新的问题 修复了滚动条可见性状态在滚动策略变更时未正确更新的问题。添加了对 policyChanged 信号的处理程序,触发状态条件重新计算,确保滚动条根据策略设 置正确显示/隐藏。 Influence: 1. 测试在 ScrollBar.AsNeeded、ScrollBar.AlwaysOn 和 ScrollBar.AlwaysOff 策略之间切换时的滚动条可见性 2. 验证滚动条根据内容大小和策略设置正确显示和隐藏 3. 检查策略动态变化时滚动条状态转换是否平滑 4. 测试不同滚动条方向(垂直/水平)的情况 PMS: BUG-338239 --- qt6/src/qml/ScrollBar.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qt6/src/qml/ScrollBar.qml b/qt6/src/qml/ScrollBar.qml index ae3e6ecb..13d4ee18 100644 --- a/qt6/src/qml/ScrollBar.qml +++ b/qt6/src/qml/ScrollBar.qml @@ -45,6 +45,9 @@ T.ScrollBar { onSizeChanged: { Qt.callLater(() => { __calculateStateConditions() }) } + onPolicyChanged: { + Qt.callLater(() => { __calculateStateConditions() }) + } states: [ State {