diff --git a/src/webview/tabbar.cpp b/src/webview/tabbar.cpp index f7d9f35d8..ea3d56317 100644 --- a/src/webview/tabbar.cpp +++ b/src/webview/tabbar.cpp @@ -230,3 +230,17 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) } QTabBar::mouseDoubleClickEvent(event); } + +void TabBar::mousePressEvent(QMouseEvent* event) +{ + TabWidget* tabWidget = qobject_cast(parentWidget()); + if (!tabWidget) + return; + + int id = tabAt(event->pos()); + if (id != -1 && event->buttons() == Qt::MiddleButton) { + tabWidget->closeTab(id); + return; + } + QTabBar::mousePressEvent(event); +} diff --git a/src/webview/tabbar.h b/src/webview/tabbar.h index a13540ed5..c4614676d 100644 --- a/src/webview/tabbar.h +++ b/src/webview/tabbar.h @@ -70,6 +70,7 @@ private slots: private: void mouseDoubleClickEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); QSize tabSizeHint(int index) const; // void tabInserted(int index);