diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2022-09-24 10:59:40 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-09-27 12:49:04 +0000 |
commit | a996c257eebdaf4bd64bc4262977f007b2c14abd (patch) | |
tree | 4e259252662601d8e5eb5a74664b6d39236dd019 | |
parent | f889e300ad268c615c4c3a9aa58e39a686a615c1 (diff) |
QtQuick Example: Use QmlElement instead of qmlRegisterType
- The example used the old way of registering the Qml type using the
qmlRegisterType(). This is now updated to use the @QmlElement
decorator. This would also make it work with pyside6-qml.
Change-Id: I97e5233331f01fcaa58ca8d6ffa9d978d6d31e91
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit c662c744cf91f966dbc072afc6d433dbfed380fb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/quick/painteditem/painteditem.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/quick/painteditem/painteditem.py b/examples/quick/painteditem/painteditem.py index 5ae58c56f..03c59dc77 100644 --- a/examples/quick/painteditem/painteditem.py +++ b/examples/quick/painteditem/painteditem.py @@ -43,11 +43,16 @@ import sys from PySide6.QtGui import QPainter, QBrush, QColor from PySide6.QtWidgets import QApplication -from PySide6.QtQml import qmlRegisterType +from PySide6.QtQml import QmlElement from PySide6.QtCore import QUrl, Property, Signal, Qt, QPointF from PySide6.QtQuick import QQuickPaintedItem, QQuickView +QML_IMPORT_NAME = "TextBalloonPlugin" +QML_IMPORT_MAJOR_VERSION = 1 +QML_IMPORT_MINOR_VERSION = 0 # Optional + +@QmlElement class TextBalloon(QQuickPaintedItem): rightAlignedChanged = Signal() @@ -97,7 +102,6 @@ if __name__ == "__main__": app = QApplication(sys.argv) view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) - qmlRegisterType(TextBalloon, "TextBalloonPlugin", 1, 0, "TextBalloon") qml_file = Path(__file__).parent / "main.qml" view.setSource(QUrl.fromLocalFile(qml_file)) |