aboutsummaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellogl2/hellogl2.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/opengl/hellogl2/hellogl2.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/opengl/hellogl2/hellogl2.py')
-rw-r--r--examples/opengl/hellogl2/hellogl2.py13
1 files changed, 7 insertions, 6 deletions
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)