diff options
author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2023-08-07 20:46:17 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-08-10 13:44:08 +0000 |
commit | 1f599464a43aa2d0da7f2641796b17f4a323144f (patch) | |
tree | 343bc8d185b0e610e86855a17ecbf1ca584ab23b | |
parent | 07554ee6114f0d40b49997559d76ecd0f5763ec9 (diff) |
Add support for QQmlComponent in Property
Fixes: PYSIDE-2415
Change-Id: I2b19b20b1dec584667fa82abe6be2901b9580f96
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
(cherry picked from commit 37cbce96410cc48df02b25e5645851172f854ee1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/pyside6/libpysideqml/pysideqml.cpp | 2 | ||||
-rw-r--r-- | sources/pyside6/tests/QtQml/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/pyside6/tests/QtQml/qqmlcomponent_test.py | 36 |
3 files changed, 39 insertions, 0 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqml.cpp b/sources/pyside6/libpysideqml/pysideqml.cpp index aeb2e6910..3fe673fdf 100644 --- a/sources/pyside6/libpysideqml/pysideqml.cpp +++ b/sources/pyside6/libpysideqml/pysideqml.cpp @@ -11,6 +11,7 @@ #include "pysideqmlmetacallerror_p.h" #include <QtQml/QQmlPropertyMap> +#include <QtQml/QQmlComponent> #include <signalmanager.h> @@ -28,6 +29,7 @@ void init(PyObject *module) PySide::SignalManager::setQmlMetaCallErrorHandler(PySide::Qml::qmlMetaCallErrorHandler); qRegisterMetaType<QQmlPropertyMap *>(); // PYSIDE-1845, QQmlPropertyMap * properties + qRegisterMetaType<QQmlComponent *>(); // PYSIDE-2415, QQmlComponent * properties } } //namespace PySide::Qml diff --git a/sources/pyside6/tests/QtQml/CMakeLists.txt b/sources/pyside6/tests/QtQml/CMakeLists.txt index 82e7bea17..c24beb35a 100644 --- a/sources/pyside6/tests/QtQml/CMakeLists.txt +++ b/sources/pyside6/tests/QtQml/CMakeLists.txt @@ -18,6 +18,7 @@ PYSIDE_TEST(groupedproperty.py) PYSIDE_TEST(listproperty.py) PYSIDE_TEST(qqmlapplicationengine_test.py) PYSIDE_TEST(qqmlnetwork_test.py) +PYSIDE_TEST(qqmlcomponent_test.py) PYSIDE_TEST(qquickview_test.py) PYSIDE_TEST(connect_python_qml.py) PYSIDE_TEST(registerattached.py) diff --git a/sources/pyside6/tests/QtQml/qqmlcomponent_test.py b/sources/pyside6/tests/QtQml/qqmlcomponent_test.py new file mode 100644 index 000000000..5521c64fa --- /dev/null +++ b/sources/pyside6/tests/QtQml/qqmlcomponent_test.py @@ -0,0 +1,36 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import os +import sys +import unittest + +from pathlib import Path +sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import Property, QObject +from PySide6.QtQml import QQmlComponent + + +class WithComponent(QObject): + def get_component(self): + return None + + component = Property(QQmlComponent, fget=get_component) + + +class TestQmlSupport(unittest.TestCase): + + def testMetatypeValid(self): + m = WithComponent.staticMetaObject + c = m.property(m.indexOfProperty("component")) + + self.assertTrue(c.typeId() > 0) + self.assertTrue(c.typeName() == "QQmlComponent*") + self.assertTrue(c.metaType().isValid()) + + +if __name__ == '__main__': + unittest.main() |