From ff34633bd0ed169b635b520f33740a31bbafaf46 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 31 Jan 2017 13:35:32 -0800 Subject: [PATCH] QTabBar: fix vertical tabs appearance Fail to take into account vertical tabs led to that vertical tabs were displayed wrong in some cases (for example, QMovableTabWidget was one pixel shorter than it should be). Task-number: QTBUG-58266 Change-Id: I90411eeaa6055538634b62b5d5bd5fa5013b0015 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qtabbar.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index ba67baeadb..37d0f751cb 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1756,7 +1756,10 @@ void QTabBar::paintEvent(QPaintEvent *) p.drawControl(QStyle::CE_TabBarTab, tab); else { int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this); - d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); + if (verticalTabs(d->shape)) + d->movingTab->setGeometry(tab.rect.adjusted(0, -taboverlap, 0, taboverlap)); + else + d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); } } @@ -2035,7 +2038,10 @@ void QTabBarPrivate::setupMovableTab() int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q); QRect grabRect = q->tabRect(pressedIndex); - grabRect.adjust(-taboverlap, 0, taboverlap, 0); + if (verticalTabs(shape)) + grabRect.adjust(0, -taboverlap, 0, taboverlap); + else + grabRect.adjust(-taboverlap, 0, taboverlap, 0); QPixmap grabImage(grabRect.size() * q->devicePixelRatioF()); grabImage.setDevicePixelRatio(q->devicePixelRatioF()); @@ -2045,7 +2051,11 @@ void QTabBarPrivate::setupMovableTab() QStyleOptionTab tab; q->initStyleOption(&tab, pressedIndex); - tab.rect.moveTopLeft(QPoint(taboverlap, 0)); + tab.position = QStyleOptionTab::OnlyOneTab; + if (verticalTabs(shape)) + tab.rect.moveTopLeft(QPoint(0, taboverlap)); + else + tab.rect.moveTopLeft(QPoint(taboverlap, 0)); p.drawControl(QStyle::CE_TabBarTab, tab); p.end();