diff options
author | Oleg Yadrov <oleg.yadrov@qt.io> | 2017-01-31 13:35:32 -0800 |
---|---|---|
committer | Oleg Yadrov <oleg.yadrov@qt.io> | 2017-02-02 17:33:09 +0000 |
commit | ff34633bd0ed169b635b520f33740a31bbafaf46 (patch) | |
tree | 8ea32255395bee698e56701adcd3828fe592e7e9 /src/widgets/widgets/qtabbar.cpp | |
parent | 56e9221b362129712e9e2900d6bba95b48ff4039 (diff) |
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 <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/widgets/widgets/qtabbar.cpp')
-rw-r--r-- | src/widgets/widgets/qtabbar.cpp | 16 |
1 files 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(); |