aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-08-27 15:45:56 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-10-22 11:53:25 +0000
commit7c448f5c27a51a60e27a54b79e298b53312ef2a8 (patch)
tree8b3175f6bb84c9a2868d50905ffd25ac7f85f0ab /sources/pyside2/tests
parent9614cb5e47e863f036f19ac3f818253dd69bb828 (diff)
QtQml: Implement QmlElement
Equivalent to QML_ELEMENT in C++, this enables users to register classes for use in QML by using the QmlElement decorator. Change-Id: I697e486ef58b18cce4c310e4b556e28735a16d45 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtQml/registertype.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/sources/pyside2/tests/QtQml/registertype.py b/sources/pyside2/tests/QtQml/registertype.py
index e4dcd36f9..2c0577fe3 100644
--- a/sources/pyside2/tests/QtQml/registertype.py
+++ b/sources/pyside2/tests/QtQml/registertype.py
@@ -38,9 +38,13 @@ from helper.helper import adjust_filename
from PySide2.QtCore import Property, QObject, QTimer, QUrl
from PySide2.QtGui import QGuiApplication, QPen, QColor, QPainter
-from PySide2.QtQml import qmlRegisterType, ListProperty
+from PySide2.QtQml import qmlRegisterType, ListProperty, QmlElement
from PySide2.QtQuick import QQuickView, QQuickItem, QQuickPaintedItem
+QML_IMPORT_NAME = "Charts"
+QML_IMPORT_MAJOR_VERSION = 1
+
+@QmlElement
class PieSlice (QQuickPaintedItem):
def __init__(self, parent = None):
QQuickPaintedItem.__init__(self, parent)
@@ -78,6 +82,7 @@ class PieSlice (QQuickPaintedItem):
painter.drawPie(self.boundingRect(), self._fromAngle * 16, self._angleSpan * 16);
paintCalled = True
+@QmlElement
class PieChart (QQuickItem):
def __init__(self, parent = None):
QQuickItem.__init__(self, parent)
@@ -108,9 +113,6 @@ class TestQmlSupport(unittest.TestCase):
def testIt(self):
app = QGuiApplication([])
- self.assertTrue(qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart') != -1)
- self.assertTrue(qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") != -1)
-
view = QQuickView()
view.setSource(QUrl.fromLocalFile(adjust_filename('registertype.qml', __file__)))
view.show()