From 66a10a141e17be25845cd08cefa68581a951b123 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Tue, 11 Mar 2025 11:50:46 +0100 Subject: [PATCH] QTabWidget: Draw base for corner widget only if QTabBar::drawBase QTabBar draws PE_FrameTabBarBase only when drawBase is enabled, so QTabWidget should honor this as well. Otherwise, there will be an awkward line below the corner widgets but not the tab bar when disabling drawBase on the built-in QTabBar. Pick-to: 6.8 Change-Id: I7621476d66c3580282846dc924cd0b3700ce250f Reviewed-by: Axel Spoerl (cherry picked from commit d28881fa335f20947b0329bc8f537bf7b577a257) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/widgets/qtabwidget.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index b7e253dedc9..803bdc46202 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -1255,20 +1255,22 @@ void QTabWidget::paintEvent(QPaintEvent *) { Q_D(QTabWidget); if (documentMode()) { - QStylePainter p(this, tabBar()); - if (QWidget *w = cornerWidget(Qt::TopLeftCorner); w && w->isVisible()) { - QStyleOptionTabBarBase opt; - QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); - opt.rect.moveLeft(w->x() + opt.rect.x()); - opt.rect.moveTop(w->y() + opt.rect.y()); - p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); - } - if (QWidget *w = cornerWidget(Qt::TopRightCorner); w && w->isVisible()) { - QStyleOptionTabBarBase opt; - QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); - opt.rect.moveLeft(w->x() + opt.rect.x()); - opt.rect.moveTop(w->y() + opt.rect.y()); - p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); + if (d->tabs->drawBase()) { + QStylePainter p(this, tabBar()); + if (QWidget *w = cornerWidget(Qt::TopLeftCorner); w && w->isVisible()) { + QStyleOptionTabBarBase opt; + QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); + opt.rect.moveLeft(w->x() + opt.rect.x()); + opt.rect.moveTop(w->y() + opt.rect.y()); + p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); + } + if (QWidget *w = cornerWidget(Qt::TopRightCorner); w && w->isVisible()) { + QStyleOptionTabBarBase opt; + QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); + opt.rect.moveLeft(w->x() + opt.rect.x()); + opt.rect.moveTop(w->y() + opt.rect.y()); + p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); + } } return; }