From 306ecd14ccba188a1c88061715456c329c1ff79c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Mar 2021 15:31:46 +0100 Subject: 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 --- examples/opengl/hellogl2/hellogl2.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'examples/opengl/hellogl2') diff --git a/examples/opengl/hellogl2/hellogl2.py b/examples/opengl/hellogl2/hellogl2.py index bcffdf3c9..56301e047 100644 --- a/examples/opengl/hellogl2/hellogl2.py +++ b/examples/opengl/hellogl2/hellogl2.py @@ -46,7 +46,7 @@ import sys import math import numpy import ctypes -from PySide6.QtCore import QCoreApplication, Signal, SIGNAL, SLOT, Qt, QSize, QPoint +from PySide6.QtCore import QCoreApplication, Signal, SIGNAL, SLOT, Qt, QSize, QPointF from PySide6.QtGui import (QVector3D, QOpenGLFunctions, QMatrix4x4, QOpenGLContext, QSurfaceFormat) from PySide6.QtOpenGL import (QOpenGLVertexArrayObject, QOpenGLBuffer, @@ -231,7 +231,7 @@ class GLWidget(QOpenGLWidget, QOpenGLFunctions): self.xRot = 0 self.yRot = 0 self.zRot = 0 - self.lastPos = 0 + self.lastPos = QPointF() self.logo = Logo() self.vao = QOpenGLVertexArrayObject() self.logoVbo = QOpenGLBuffer() @@ -437,11 +437,12 @@ class GLWidget(QOpenGLWidget, QOpenGLFunctions): self.proj.perspective(45, width / height, 0.01, 100) def mousePressEvent(self, event): - self.lastPos = QPoint(event.pos()) + self.lastPos = event.position() def mouseMoveEvent(self, event): - dx = event.x() - self.lastPos.x() - dy = event.y() - self.lastPos.y() + pos = event.position() + dx = pos.x() - self.lastPos.x() + dy = pos.y() - self.lastPos.y() if event.buttons() & Qt.LeftButton: self.setXRotation(self.xRot + 8 * dy) @@ -450,7 +451,7 @@ class GLWidget(QOpenGLWidget, QOpenGLFunctions): self.setXRotation(self.xRot + 8 * dy) self.setZRotation(self.zRot + 8 * dx) - self.lastPos = QPoint(event.pos()) + self.lastPos = pos if __name__ == '__main__': app = QApplication(sys.argv) -- cgit v1.2.3