aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtquick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtquick.cpp')
-rw-r--r--sources/pyside6/PySide6/glue/qtquick.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/glue/qtquick.cpp b/sources/pyside6/PySide6/glue/qtquick.cpp
new file mode 100644
index 000000000..060418faf
--- /dev/null
+++ b/sources/pyside6/PySide6/glue/qtquick.cpp
@@ -0,0 +1,27 @@
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+// @snippet qtquick
+PySide::initQuickSupport(module);
+// @snippet qtquick
+
+// @snippet qsgeometry-vertexdataaspoint2d
+auto *points = %CPPSELF->vertexDataAsPoint2D();
+const Py_ssize_t vertexCount = %CPPSELF->vertexCount();
+%PYARG_0 = PyList_New(vertexCount);
+for (Py_ssize_t i = 0; i < vertexCount; ++i) {
+ QSGGeometry::Point2D p = points[i];
+ PyList_SET_ITEM(%PYARG_0, i, %CONVERTTOPYTHON[QSGGeometry::Point2D](p));
+}
+// @snippet qsgeometry-vertexdataaspoint2d
+
+// @snippet qsgeometry-setvertexdataaspoint2d
+const qsizetype vertexCount = %CPPSELF->vertexCount();
+if (vertexCount != %1.size()) {
+ PyErr_SetString(PyExc_RuntimeError, "size mismatch");
+ return {};
+}
+
+QSGGeometry::Point2D *points = %CPPSELF->vertexDataAsPoint2D();
+std::copy(%1.cbegin(), %1.cend(), points);
+// @snippet qsgeometry-setvertexdataaspoint2d