diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index 22ae6d73c..0dbb285ef 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -36,6 +36,12 @@ #include #include +class QMovableTabWidget : public QWidget +{ +public: + QPixmap m_pixmap; +}; + ComboTabBar::ComboTabBar(QWidget* parent) : QWidget(parent) , m_mainTabBar(0) @@ -1344,6 +1350,21 @@ void TabBarHelper::paintEvent(QPaintEvent *) } else { int taboverlap = style()->pixelMetric(QStyle::PM_TabBarTabOverlap, nullptr, this); m_movingTab->setGeometry(tab.rect.adjusted(-taboverlap, 0, taboverlap, 0)); + + QRect grabRect = tabRect(selected); + grabRect.adjust(-taboverlap, 0, taboverlap, 0); + QPixmap grabImage(grabRect.size() * devicePixelRatioF()); + grabImage.setDevicePixelRatio(devicePixelRatioF()); + grabImage.fill(Qt::transparent); + QStylePainter p(&grabImage, this); + p.initFrom(this); + if (tabDragOffset != 0) { + tab.position = QStyleOptionTab::OnlyOneTab; + } + tab.rect.moveTopLeft(QPoint(taboverlap, 0)); + p.drawControl(QStyle::CE_TabBarTab, tab); + m_movingTab->m_pixmap = grabImage; + m_movingTab->update(); } } @@ -1409,7 +1430,7 @@ void TabBarHelper::mouseMoveEvent(QMouseEvent *event) for (QObject *object : objects) { QWidget *widget = qobject_cast(object); if (widget && widget->geometry() == grabRect) { - m_movingTab = widget; + m_movingTab = static_cast(widget); break; } } diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index 5e7d6593a..52f39db77 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -285,7 +285,7 @@ private: int m_pressedIndex; bool m_dragInProgress; QPoint m_dragStartPosition; - QWidget *m_movingTab = nullptr; + class QMovableTabWidget *m_movingTab = nullptr; bool m_activeTabBar; bool m_isPinnedTabBar; bool m_useFastTabSizeHint;