@@ -221,7 +221,7 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
221
221
ev->accept ();
222
222
int left, top, right, bottom;
223
223
_this->getContentsMargins (&left, &top, &right, &bottom);
224
- QPoint moveToPos = _this-> mapToParent ( ev->pos () ) - DragStartMousePosition;
224
+ QPoint moveToPos = ev->globalPos ( ) - DragStartMousePosition;
225
225
moveToPos.setY (0 );
226
226
_this->move (moveToPos);
227
227
_this->raise ();
@@ -266,14 +266,16 @@ bool DockWidgetTabPrivate::startFloating(eDragState DraggingState)
266
266
267
267
if (DraggingFloatingWidget == DraggingState)
268
268
{
269
- FloatingWidget->startFloating (DragStartMousePosition, Size, DraggingFloatingWidget, _this);
269
+ FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
270
+ Size, DraggingFloatingWidget, _this);
270
271
auto Overlay = DockWidget->dockManager ()->containerOverlay ();
271
272
Overlay->setAllowedAreas (OuterDockAreas);
272
273
this ->FloatingWidget = FloatingWidget;
273
274
}
274
275
else
275
276
{
276
- FloatingWidget->startFloating (DragStartMousePosition, Size, DraggingInactive, nullptr );
277
+ FloatingWidget->startFloating (_this->mapFromGlobal (DragStartMousePosition),
278
+ Size, DraggingInactive, nullptr );
277
279
}
278
280
279
281
return true ;
@@ -304,7 +306,7 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
304
306
if (ev->button () == Qt::LeftButton)
305
307
{
306
308
ev->accept ();
307
- d->DragStartMousePosition = ev->pos ();
309
+ d->DragStartMousePosition = ev->globalPos ();
308
310
d->DragState = DraggingMousePressed;
309
311
emit clicked ();
310
312
return ;
@@ -372,7 +374,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
372
374
}
373
375
374
376
// Maybe a fixed drag distance is better here ?
375
- int DragDistanceY = qAbs (d->DragStartMousePosition .y () - ev->pos ().y ());
377
+ int DragDistanceY = qAbs (d->DragStartMousePosition .y () - ev->globalPos ().y ());
376
378
if (DragDistanceY >= CDockManager::startDragDistance ())
377
379
{
378
380
// If this is the last dock area in a dock container with only
@@ -399,7 +401,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
399
401
return ;
400
402
}
401
403
else if (d->DockArea ->openDockWidgetsCount () > 1
402
- && (ev->pos () - d->DragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
404
+ && (ev->globalPos () - d->DragStartMousePosition ).manhattanLength () >= QApplication::startDragDistance ()) // Wait a few pixels before start moving
403
405
{
404
406
// If we start dragging the tab, we save its inital position to
405
407
// restore it later
@@ -424,15 +426,15 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
424
426
return ;
425
427
}
426
428
427
- d->DragStartMousePosition = ev->pos ();
429
+ d->DragStartMousePosition = ev->globalPos ();
428
430
QMenu Menu (this );
429
431
auto Action = Menu.addAction (tr (" Detach" ), this , SLOT (detachDockWidget ()));
430
432
Action->setEnabled (d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable));
431
433
Menu.addSeparator ();
432
434
Action = Menu.addAction (tr (" Close" ), this , SIGNAL (closeRequested ()));
433
435
Action->setEnabled (isClosable ());
434
436
Menu.addAction (tr (" Close Others" ), this , SIGNAL (closeOtherTabsRequested ()));
435
- Menu.exec (mapToGlobal ( ev->pos () ));
437
+ Menu.exec (ev->globalPos ( ));
436
438
}
437
439
438
440
@@ -549,7 +551,7 @@ void CDockWidgetTab::mouseDoubleClickEvent(QMouseEvent *event)
549
551
if ((!d->DockArea ->dockContainer ()->isFloating () || d->DockArea ->dockWidgetsCount () > 1 )
550
552
&& d->DockWidget ->features ().testFlag (CDockWidget::DockWidgetFloatable))
551
553
{
552
- d->DragStartMousePosition = event->pos ();
554
+ d->DragStartMousePosition = event->globalPos ();
553
555
d->startFloating (DraggingInactive);
554
556
}
555
557
@@ -587,21 +589,21 @@ void CDockWidgetTab::detachDockWidget()
587
589
{
588
590
return ;
589
591
}
590
- d->DragStartMousePosition = mapFromGlobal ( QCursor::pos () );
592
+ d->DragStartMousePosition = QCursor::pos ();
591
593
d->startFloating (DraggingInactive);
592
594
}
593
595
594
596
595
597
// ============================================================================
596
598
bool CDockWidgetTab::event (QEvent *e)
597
599
{
598
- #ifndef QT_NO_TOOLTIP
600
+ #ifndef QT_NO_TOOLTIP
599
601
if (e->type () == QEvent::ToolTipChange)
600
602
{
601
603
const auto text = toolTip ();
602
604
d->TitleLabel ->setToolTip (text);
603
605
}
604
- #endif
606
+ #endif
605
607
return Super::event (e);
606
608
}
607
609
0 commit comments