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>
This commit is contained in:
parent
56e9221b36
commit
ff34633bd0
@ -1756,6 +1756,9 @@ void QTabBar::paintEvent(QPaintEvent *)
|
|||||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||||
else {
|
else {
|
||||||
int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);
|
int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0, this);
|
||||||
|
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));
|
d->movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2035,6 +2038,9 @@ void QTabBarPrivate::setupMovableTab()
|
|||||||
|
|
||||||
int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
|
int taboverlap = q->style()->pixelMetric(QStyle::PM_TabBarTabOverlap, 0 ,q);
|
||||||
QRect grabRect = q->tabRect(pressedIndex);
|
QRect grabRect = q->tabRect(pressedIndex);
|
||||||
|
if (verticalTabs(shape))
|
||||||
|
grabRect.adjust(0, -taboverlap, 0, taboverlap);
|
||||||
|
else
|
||||||
grabRect.adjust(-taboverlap, 0, taboverlap, 0);
|
grabRect.adjust(-taboverlap, 0, taboverlap, 0);
|
||||||
|
|
||||||
QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());
|
QPixmap grabImage(grabRect.size() * q->devicePixelRatioF());
|
||||||
@ -2045,6 +2051,10 @@ void QTabBarPrivate::setupMovableTab()
|
|||||||
|
|
||||||
QStyleOptionTab tab;
|
QStyleOptionTab tab;
|
||||||
q->initStyleOption(&tab, pressedIndex);
|
q->initStyleOption(&tab, pressedIndex);
|
||||||
|
tab.position = QStyleOptionTab::OnlyOneTab;
|
||||||
|
if (verticalTabs(shape))
|
||||||
|
tab.rect.moveTopLeft(QPoint(0, taboverlap));
|
||||||
|
else
|
||||||
tab.rect.moveTopLeft(QPoint(taboverlap, 0));
|
tab.rect.moveTopLeft(QPoint(taboverlap, 0));
|
||||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||||
p.end();
|
p.end();
|
||||||
|
Loading…
Reference in New Issue
Block a user