From dbc747bdeb6489e9bb34f289ca722861d8b039e7 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Thu, 13 Aug 2026 22:05:52 +0800 Subject: [PATCH] fix: correct scroll button enabled state after lazy layoutTabs in DTabBar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 在 DTabBarPrivate::tabLayoutChange() 中增加 makeVisible(currentIndex()) 调用; 2. 修复惰性 layoutTabs 路径(如 paintEvent 经 tabRect() 触发)下左右滚动按钮 enabled 状态反转的问题; ===================================== 1. added makeVisible(currentIndex()) call in DTabBarPrivate::tabLayoutChange(); 2. fixed scroll button enabled state inversion in lazy layoutTabs path (e.g. triggered via tabRect() in paintEvent); Log: 修复窗口缩至最小、多 tab 溢出时 DTabBar 左右滚动按钮可点击状态反转的问题,确保惰性布局后按钮状态与实际滚动位置一致 --- src/widgets/dtabbar.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/dtabbar.cpp b/src/widgets/dtabbar.cpp index 7584a4867..b2ad850e5 100644 --- a/src/widgets/dtabbar.cpp +++ b/src/widgets/dtabbar.cpp @@ -1589,6 +1589,10 @@ void DTabBarPrivate::tabLayoutChange() q->tabLayoutChange(); // 更新关闭按钮的显示 updateCloseButtonVisible(); + // 修正滚动按钮的启用状态:layoutTabs() 会将 leftB 重置为 disabled, + // 需根据实际 scrollOffset 重新计算,修复惰性布局路径(如 paintEvent + // 中经 tabRect() 触发的 layoutTabs)下左右滚动按钮 enabled 状态反转的问题。 + makeVisible(currentIndex()); } void DTabBarPrivate::initStyleOption(QStyleOptionTab *option, int tabIndex) const