QSGGeometry does not work on PySide2
-
Did you open an issue on the bug tracker ?
-
Thank you !
-
Quick update. I reviewed the ticket again and realized there is a patch there. I recomplied PySide6 with the patch applied and I can say that vertexDataAsPoint2D() now does return a list of Point2D instead of just Point2D. In the ticket the developer states that the fix crashes submitted example. I am yet to confirm whether this causes any issues on my side.
-
Thanks for the feedback !
Can you upload your minimal example on the report ?
It can help fix this issue as well. -
Hi SGaist,
Here's the code. It's really basic:
# This Python file uses the following encoding: utf-8 import os from pathlib import Path import sys from PySide6.QtGui import QGuiApplication, QColor from PySide6.QtQml import QQmlApplicationEngine, qmlRegisterType from PySide6.QtQuick import QQuickItem, QSGGeometryNode, QSGGeometry, QSGFlatColorMaterial, QSGNode class JustItem(QQuickItem): def __init__(self, parent=None): super().__init__(parent) self.setFlag(QQuickItem.ItemHasContents, enabled=True) def updatePaintNode(self, node, update_data): if node is None: node = QSGGeometryNode() geometry = QSGGeometry(QSGGeometry.defaultAttributes_Point2D(), 4) geometry.setLineWidth(1) geometry.setDrawingMode(QSGGeometry.DrawTriangles) material = QSGFlatColorMaterial() material.setColor(QColor(255, 0, 0, 127)) node.setGeometry(geometry) node.setMaterial(material) node.setFlag(QSGNode.OwnsGeometry) node.setFlag(QSGNode.OwnsMaterial) else: geometry = node vertex_data = geometry.vertexDataAsPoint2D() vertex_data[0].set(10, 10) vertex_data[1].set(100, 10) vertex_data[2].set(100, 100) vertex_data[3].set(10, 100) node.markDirty(QSGNode.DirtyGeometry) return node if __name__ == "__main__": qmlRegisterType(JustItem, "PythonTypes", 1, 0, "JustItem") app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml")) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec())and main.qml:
import QtQuick import QtQuick.Window import PythonTypes 1.0 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") JustItem { } }If you run it without the patch, it will complain that Point2D is not subscriptible (because Point2D and not a list of Point2Ds is returned). If you run it with the patch applied, it will segfault.
-
Thanks for posting it here but you should add it to the bug report as well. It will be easier to find over there.