aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qttest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/PySide6/glue/qttest.cpp')
-rw-r--r--sources/pyside6/PySide6/glue/qttest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/glue/qttest.cpp b/sources/pyside6/PySide6/glue/qttest.cpp
new file mode 100644
index 000000000..626cc1608
--- /dev/null
+++ b/sources/pyside6/PySide6/glue/qttest.cpp
@@ -0,0 +1,24 @@
+// Copyright (C) 2021 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
+
+/*********************************************************************
+ * INJECT CODE
+ ********************************************************************/
+
+// @snippet qsignalspy-signal
+auto *signalInst = reinterpret_cast<PySideSignalInstance *>(%PYARG_1);
+PyObject *emitterPyObject = PySide::Signal::getObject(signalInst);
+QObject* emitter = %CONVERTTOCPP[QObject *](emitterPyObject);
+QByteArray signature = PySide::Signal::getSignature(signalInst);
+if (!signature.isEmpty())
+ signature.prepend('2'); // SIGNAL() macro
+
+if (emitter == nullptr || signature.isEmpty()) {
+ QByteArray error = QByteArrayLiteral("Wrong parameter (")
+ + (%PYARG_1)->ob_type->tp_name
+ + QByteArrayLiteral(") passed, QSignalSpy requires a signal.");
+ PyErr_SetString(PyExc_ValueError, error.constData());
+ return -1;
+}
+%0 = new QSignalSpyWrapper(emitter, signature.constData());
+// @snippet qsignalspy-signal