Skip to content

Commit 561141f

Browse files
hillwoodroc18202781743
authored andcommitted
fix: Fix build with Qt 6.10.2
Qt 6.10.2 removed QTabBarPrivate::paintWithOffsets, causing build failures in DTabBar. Adjust tab button positioning logic to rely solely on dragOffset for Qt >= 6.10.2, while preserving the original behavior for older Qt versions. This aligns the implementation with the updated QTabBar internals and restores compatibility with Qt 6.10.2.
1 parent b65a28e commit 561141f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/widgets/dtabbar.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,11 @@ void DTabBarPrivate::layoutTab(int index)
699699
if (tab->leftWidget) {
700700
QRect rect = style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, this);
701701
QPoint p = rect.topLeft();
702+
#if QT_VERSION <= QT_VERSION_CHECK(6, 10, 1)
702703
if ((index == d->pressedIndex) || d->paintWithOffsets) {
704+
#else
705+
if (d->at(index)->dragOffset != 0) {
706+
#endif
703707
if (vertical)
704708
p.setY(p.y() + d->at(index)->dragOffset);
705709
else
@@ -711,7 +715,11 @@ void DTabBarPrivate::layoutTab(int index)
711715
if (tab->rightWidget) {
712716
QRect rect = style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, this);
713717
QPoint p = rect.topLeft();
718+
#if QT_VERSION <= QT_VERSION_CHECK(6, 10, 1)
714719
if ((index == d->pressedIndex) || d->paintWithOffsets) {
720+
#else
721+
if (d->at(index)->dragOffset != 0) {
722+
#endif
715723
if (vertical)
716724
p.setY(p.y() + tab->dragOffset);
717725
else
@@ -1234,7 +1242,11 @@ void DTabBarPrivate::paintEvent(QPaintEvent *e)
12341242
// 强制让文本居中
12351243
tab.rightButtonSize = QSize();
12361244

1245+
#if QT_VERSION <= QT_VERSION_CHECK(6, 10, 1)
12371246
if (d->paintWithOffsets && d->at(i)->dragOffset != 0) {
1247+
#else
1248+
if (d->at(i)->dragOffset != 0) {
1249+
#endif
12381250
if (vertical) {
12391251
tab.rect.moveTop(tab.rect.y() + d->at(i)->dragOffset);
12401252
} else {
@@ -1286,7 +1298,11 @@ void DTabBarPrivate::paintEvent(QPaintEvent *e)
12861298
// 强制让文本居中
12871299
tab.rightButtonSize = QSize();
12881300

1301+
#if QT_VERSION <= QT_VERSION_CHECK(6, 10, 1)
12891302
if (d->paintWithOffsets && d->at(selected)->dragOffset != 0) {
1303+
#else
1304+
if (d->at(selected)->dragOffset != 0) {
1305+
#endif
12901306
if (vertical) {
12911307
tab.rect.moveTop(tab.rect.y() + d->at(selected)->dragOffset);
12921308
} else {

0 commit comments

Comments
 (0)