diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 300fd1c..f8835a7 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -488,7 +488,7 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line if you want to use opaque undocking and // opaque splitter resizing - // CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig); + //CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig); // uncomment the following line if you want a fixed tab width that does // not change if the visibility of the close button changes diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 78f527f..b568556 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -215,6 +215,8 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev) QPoint Distance = ev->globalPos() - GlobalDragStartMousePosition; Distance.setY(0); auto TargetPos = Distance + TabDragStartPosition; + TargetPos.rx() = qMax(TargetPos.x(), 0); + TargetPos.rx() = qMin(_this->parentWidget()->rect().right() - _this->width() + 1, TargetPos.rx()); _this->move(TargetPos); _this->raise(); } @@ -357,19 +359,18 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev) } // move tab - bool TabOutsideBar = false; if (d->isDraggingState(DraggingTab)) { // Moving the tab is always allowed because it does not mean moving the // dock widget around d->moveTab(ev); - TabOutsideBar = (geometry().right() < 0) || (geometry().left() > parentWidget()->rect().right()); } - + auto MappedPos = mapToParent(ev->pos()); + bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right()); // Maybe a fixed drag distance is better here ? int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - ev->globalPos().y()); - if (DragDistanceY >= CDockManager::startDragDistance() || TabOutsideBar) + if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar) { // If this is the last dock area in a dock container with only // one single dock widget it does not make sense to move it to a new