aboutsummaryrefslogtreecommitdiffstats
path: root/examples/corelib/threads/mandelbrot.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-19 15:31:46 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-19 18:29:40 +0100
commit306ecd14ccba188a1c88061715456c329c1ff79c (patch)
tree2515a0f138efd129d9921c7d4b460b7f9a58d9bf /examples/corelib/threads/mandelbrot.py
parent3777356c08258f74413187e2406679f3b0c89b07 (diff)
Port examples away from deprecated QMouseEvent::pos()
As a drive by, fix the left-over QtCharts callout example to work after 227020b118fa38ada1d8bd579593dae61f6e3881. Pick-to: 6.0 Task-number: PYSIDE-1122 Change-Id: I945b57950014e882d4efd3cb0cab47262ad108b6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/corelib/threads/mandelbrot.py')
-rw-r--r--examples/corelib/threads/mandelbrot.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/examples/corelib/threads/mandelbrot.py b/examples/corelib/threads/mandelbrot.py
index 2d82cd65a..1cdf903d5 100644
--- a/examples/corelib/threads/mandelbrot.py
+++ b/examples/corelib/threads/mandelbrot.py
@@ -42,7 +42,7 @@
"""PySide6 port of the corelib/threads/mandelbrot example from Qt v5.x, originating from PyQt"""
-from PySide6.QtCore import (Signal, QMutex, QMutexLocker, QPoint, QSize, Qt,
+from PySide6.QtCore import (Signal, QMutex, QMutexLocker, QPointF, QSize, Qt,
QThread, QWaitCondition)
from PySide6.QtGui import QColor, QImage, QPainter, QPixmap, qRgb
from PySide6.QtWidgets import QApplication, QWidget
@@ -215,8 +215,8 @@ class MandelbrotWidget(QWidget):
self.thread = RenderThread()
self.pixmap = QPixmap()
- self.pixmapOffset = QPoint()
- self.lastDragPos = QPoint()
+ self.pixmapOffset = QPointF()
+ self.lastDragPos = QPointF()
self.centerX = DefaultCenterX
self.centerY = DefaultCenterY
@@ -295,18 +295,19 @@ class MandelbrotWidget(QWidget):
def mousePressEvent(self, event):
if event.buttons() == Qt.LeftButton:
- self.lastDragPos = QPoint(event.pos())
+ self.lastDragPos = event.position()
def mouseMoveEvent(self, event):
if event.buttons() & Qt.LeftButton:
- self.pixmapOffset += event.pos() - self.lastDragPos
- self.lastDragPos = QPoint(event.pos())
+ pos = event.position()
+ self.pixmapOffset += pos - self.lastDragPos
+ self.lastDragPos = pos
self.update()
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton:
- self.pixmapOffset += event.pos() - self.lastDragPos
- self.lastDragPos = QPoint()
+ self.pixmapOffset += event.position() - self.lastDragPos
+ self.lastDragPos = QPointF()
deltaX = (self.width() - self.pixmap.width()) / 2 - self.pixmapOffset.x()
deltaY = (self.height() - self.pixmap.height()) / 2 - self.pixmapOffset.y()
@@ -317,8 +318,8 @@ class MandelbrotWidget(QWidget):
return
self.pixmap = QPixmap.fromImage(image)
- self.pixmapOffset = QPoint()
- self.lastDragPosition = QPoint()
+ self.pixmapOffset = QPointF()
+ self.lastDragPosition = QPointF()
self.pixmapScale = scaleFactor
self.update()