diff --git a/UI/media-slider.cpp b/UI/media-slider.cpp index 4690960da..86c310926 100644 --- a/UI/media-slider.cpp +++ b/UI/media-slider.cpp @@ -22,7 +22,8 @@ MediaSlider::MediaSlider(QWidget *parent) : SliderIgnoreScroll(parent) void MediaSlider::mouseMoveEvent(QMouseEvent *event) { - int val = minimum() + ((maximum() - minimum()) * event->x()) / width(); + int val = minimum() + + ((maximum() - minimum()) * event->pos().x()) / width(); if (val > maximum()) val = maximum(); diff --git a/UI/menu-button.cpp b/UI/menu-button.cpp index cfdcdb8b7..c2da16e8f 100644 --- a/UI/menu-button.cpp +++ b/UI/menu-button.cpp @@ -24,7 +24,7 @@ void MenuButton::keyPressEvent(QKeyEvent *event) void MenuButton::mousePressEvent(QMouseEvent *event) { if (menu()) { - if (width() - event->x() <= 30) + if (width() - event->pos().x() <= 30) showMenu(); else setDown(true); diff --git a/UI/scene-tree.cpp b/UI/scene-tree.cpp index 8e3006305..469710962 100644 --- a/UI/scene-tree.cpp +++ b/UI/scene-tree.cpp @@ -124,7 +124,11 @@ void SceneTree::dropEvent(QDropEvent *event) float wid = contentsRect().width() - scrollWid - 1; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QPoint point = event->position().toPoint(); +#else QPoint point = event->pos(); +#endif int x = (float)point.x() / wid * ceil(wid / maxWidth); int y = point.y() / itemHeight; @@ -157,7 +161,11 @@ void SceneTree::RepositionGrid(QDragMoveEvent *event) float wid = contentsRect().width() - scrollWid - 1; if (event) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QPoint point = event->position().toPoint(); +#else QPoint point = event->pos(); +#endif int x = (float)point.x() / wid * ceil(wid / maxWidth); int y = point.y() / itemHeight; diff --git a/UI/source-tree.cpp b/UI/source-tree.cpp index 6b8ff5138..5de3d6639 100644 --- a/UI/source-tree.cpp +++ b/UI/source-tree.cpp @@ -1186,7 +1186,14 @@ void SourceTree::dropEvent(QDropEvent *event) QModelIndexList indices = selectedIndexes(); DropIndicatorPosition indicator = dropIndicatorPosition(); - int row = indexAt(event->pos()).row(); + int row = indexAt( +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + event->position().toPoint() +#else + event->pos() +#endif + ) + .row(); bool emptyDrop = row == -1; if (emptyDrop) { diff --git a/UI/window-basic-interaction.cpp b/UI/window-basic-interaction.cpp index 3527dc678..5c31c4633 100644 --- a/UI/window-basic-interaction.cpp +++ b/UI/window-basic-interaction.cpp @@ -319,8 +319,9 @@ bool OBSBasicInteraction::HandleMouseClickEvent(QMouseEvent *event) //if (event->flags().testFlag(Qt::MouseEventCreatedDoubleClick)) // clickCount = 2; - bool insideSource = GetSourceRelativeXY(event->x(), event->y(), - mouseEvent.x, mouseEvent.y); + QPoint pos = event->pos(); + bool insideSource = GetSourceRelativeXY(pos.x(), pos.y(), mouseEvent.x, + mouseEvent.y); if (mouseUp || insideSource) obs_source_send_mouse_click(source, &mouseEvent, button, @@ -337,7 +338,8 @@ bool OBSBasicInteraction::HandleMouseMoveEvent(QMouseEvent *event) if (!mouseLeave) { mouseEvent.modifiers = TranslateQtMouseEventModifiers(event); - mouseLeave = !GetSourceRelativeXY(event->x(), event->y(), + QPoint pos = event->pos(); + mouseLeave = !GetSourceRelativeXY(pos.x(), pos.y(), mouseEvent.x, mouseEvent.y); } diff --git a/UI/window-basic-preview.cpp b/UI/window-basic-preview.cpp index 7eebf37f7..11c431fad 100644 --- a/UI/window-basic-preview.cpp +++ b/UI/window-basic-preview.cpp @@ -39,10 +39,10 @@ vec2 OBSBasicPreview::GetMouseEventPos(QMouseEvent *event) OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); float pixelRatio = main->devicePixelRatioF(); float scale = pixelRatio / main->previewScale; + QPoint qtPos = event->pos(); vec2 pos; - vec2_set(&pos, - (float(event->x()) - main->previewX / pixelRatio) * scale, - (float(event->y()) - main->previewY / pixelRatio) * scale); + vec2_set(&pos, (qtPos.x() - main->previewX / pixelRatio) * scale, + (qtPos.y() - main->previewY / pixelRatio) * scale); return pos; } @@ -499,11 +499,17 @@ void OBSBasicPreview::wheelEvent(QWheelEvent *event) void OBSBasicPreview::mousePressEvent(QMouseEvent *event) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QPointF pos = event->position(); +#else + QPointF pos = event->localPos(); +#endif + if (scrollMode && IsFixedScaling() && event->button() == Qt::LeftButton) { setCursor(Qt::ClosedHandCursor); - scrollingFrom.x = event->x(); - scrollingFrom.y = event->y(); + scrollingFrom.x = pos.x(); + scrollingFrom.y = pos.x(); return; } @@ -519,8 +525,8 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event) OBSBasic *main = reinterpret_cast(App()->GetMainWindow()); float pixelRatio = main->devicePixelRatioF(); - float x = float(event->x()) - main->previewX / pixelRatio; - float y = float(event->y()) - main->previewY / pixelRatio; + float x = pos.x() - main->previewX / pixelRatio; + float y = pos.y() - main->previewY / pixelRatio; Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); bool altDown = (modifiers & Qt::AltModifier); bool shiftDown = (modifiers & Qt::ShiftModifier); @@ -1459,11 +1465,17 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) { changed = true; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QPointF qtPos = event->position(); +#else + QPointF qtPos = event->localPos(); +#endif + if (scrollMode && event->buttons() == Qt::LeftButton) { - scrollingOffset.x += event->x() - scrollingFrom.x; - scrollingOffset.y += event->y() - scrollingFrom.y; - scrollingFrom.x = event->x(); - scrollingFrom.y = event->y(); + scrollingOffset.x += qtPos.x() - scrollingFrom.x; + scrollingOffset.y += qtPos.y() - scrollingFrom.y; + scrollingFrom.x = qtPos.x(); + scrollingFrom.y = qtPos.y(); emit DisplayResized(); return; } @@ -1537,8 +1549,8 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event) OBSBasic *main = reinterpret_cast( App()->GetMainWindow()); float scale = main->devicePixelRatioF(); - float x = float(event->x()) - main->previewX / scale; - float y = float(event->y()) - main->previewY / scale; + float x = qtPos.x() - main->previewX / scale; + float y = qtPos.y() - main->previewY / scale; vec2_set(&startPos, x, y); updateCursor = true; } diff --git a/UI/window-projector.cpp b/UI/window-projector.cpp index e19cdabc6..d3f8a34ab 100644 --- a/UI/window-projector.cpp +++ b/UI/window-projector.cpp @@ -232,8 +232,9 @@ void OBSProjector::mouseDoubleClickEvent(QMouseEvent *event) return; if (event->button() == Qt::LeftButton) { + QPoint pos = event->pos(); OBSSource src = - multiview->GetSourceByPosition(event->x(), event->y()); + multiview->GetSourceByPosition(pos.x(), pos.y()); if (!src) return; @@ -283,8 +284,9 @@ void OBSProjector::mousePressEvent(QMouseEvent *event) return; if (event->button() == Qt::LeftButton) { + QPoint pos = event->pos(); OBSSource src = - multiview->GetSourceByPosition(event->x(), event->y()); + multiview->GetSourceByPosition(pos.x(), pos.y()); if (!src) return;