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.9 6.8
Change-Id: I7621476d66c3580282846dc924cd0b3700ce250f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Kai Uwe Broulik 2025-03-11 11:50:46 +01:00
parent dd54e32d9a
commit d28881fa33

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