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 <axel.spoerl@qt.io>
(cherry picked from commit d28881fa335f20947b0329bc8f537bf7b577a257)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Kai Uwe Broulik 2025-03-11 11:50:46 +01:00 committed by Qt Cherry-pick Bot
parent 4a352937e3
commit 66a10a141e

View File

@ -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;
}