aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideqml
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-02 16:03:11 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-03 16:17:42 +0100
commitcf40e624e603dc468ec585ecddc9fbf1ee0ccddd (patch)
treeb03c2a9c3bf1a112ecba129f85cf96d46c7a6dd7 /sources/pyside6/libpysideqml
parente39f31bbae4c6699d5919bc046d1b9616c3f55c3 (diff)
Fix grouped QML properties
Register the meta type using QQmlMetaTypeInterface and use them when creating properties in the dynamic metaobject builder. This at least fixes grouped properties when decorators are used. It does not work when using plain qmlRegisterType() due to an ordering problem. Fixes: PYSIDE-1836 Change-Id: I06db020a1ccd169da7a745cc5ef42d38ce35f5f5 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/libpysideqml')
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlregistertype.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp b/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
index ad839ec96..05a7bbffb 100644
--- a/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
@@ -60,6 +60,7 @@
#include <QtQml/qqml.h>
#include <QtQml/QJSValue>
#include <QtQml/QQmlListProperty>
+#include <private/qqmlmetatype_p.h>
static PySide::Qml::QuickRegisterItemFunction quickRegisterItemFunction = nullptr;
@@ -140,15 +141,21 @@ int qmlRegisterType(PyObject *pyObj, const char *uri, int versionMajor,
// Register as simple QObject rather than Qt Quick item.
if (!registered) {
+ using QObjectQmlList = QQmlListProperty<QObject>;
// Incref the type object, don't worry about decref'ing it because
// there's no way to unregister a QML type.
Py_INCREF(pyObj);
type.structVersion = 0;
- // FIXME: Fix this to assign new type ids each time.
- type.typeId = QMetaType(QMetaType::QObjectStar);
- type.listId = QMetaType::fromType<QQmlListProperty<QObject> >();
+ const QByteArray typeName(pyObjType->tp_name);
+ QByteArray ptrType = typeName + '*';
+ QByteArray listType = QByteArrayLiteral("QQmlListProperty<") + typeName + '>';
+
+ type.typeId = QMetaType(new QQmlMetaTypeInterface(ptrType, static_cast<QObject **>(nullptr)));
+ type.listId = QMetaType(new QQmlListMetaTypeInterface(listType,
+ static_cast<QObjectQmlList*>(nullptr),
+ type.typeId.iface()));
const auto typeInfo = qmlTypeInfo(pyObj);
auto info = qmlAttachedInfo(pyObjType, typeInfo);
type.attachedPropertiesFunction = info.factory;