summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-06-05 11:29:11 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-10 06:54:00 +0000
commit460ad31c7a1cd88b843b654fb23ffc7e01dc52e4 (patch)
tree3967b875c9317705eaf1d332f0a91009360c1bfc /src
parent93450a6ab263bc940ce4fc82836c965a5ea9bb4e (diff)
QTabBar: don't let tab shine through (semi-transparent) scroll buttons
On styles where the tab bar's scroll buttons are rendered semi- transparently, or where the buttons don't fill their entire rect (for example have rounded edges), the tab that's covered by the buttons should not shine through the gaps, or even shine through the button. Clip the painter so that the area of each button is not painted by the tabs. Fixes: QTBUG-50866 Change-Id: Ie81f6d260f36d5a17868822e683745844a6a6b2f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 0965cf0f1e49185097b0698e51ea9ad464eaa573) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qtabbar.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index a390f9ec0d..0954a02d07 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1833,6 +1833,20 @@ void QTabBar::paintEvent(QPaintEvent *)
if (d->drawBase)
p.drawPrimitive(QStyle::PE_FrameTabBarBase, optTabBase);
+ // the buttons might be semi-transparent or not fill their rect, but we don't
+ // want the tab underneath to shine through, so clip the button area; QTBUG-50866
+ if (d->leftB->isVisible() || d->rightB->isVisible()) {
+ QStyleOption opt;
+ opt.initFrom(this);
+ QRegion buttonRegion;
+ if (d->leftB->isVisible())
+ buttonRegion |= style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, this);
+ if (d->rightB->isVisible())
+ buttonRegion |= style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, this);
+ if (!buttonRegion.isEmpty())
+ p.setClipRegion(QRegion(rect()) - buttonRegion);
+ }
+
for (int i = 0; i < d->tabList.count(); ++i) {
const auto tab = d->tabList.at(i);
if (!tab->visible)