diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-07-02 10:38:45 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-07-04 11:55:52 +0200 |
commit | 08d61b56fa9e901b807b67b07f187e0f54e7551c (patch) | |
tree | 2408c7fb6ebb7fcb4267871e9ab0c34c861d1a56 /sources/pyside6/tests | |
parent | 0e920a721830ca0ed900492756335ceafea1fedd (diff) |
libpyside: Fix parameters for connections with contexts
Use the new SignalManager::callPythonMetaMethod() overload
introduced by ed8fc457e04f4ead8a3b2a2da797bdc14bd5b210 in
PySideQSlotObject to convert the void ** arguments to Python.
Amends acab25a3ccb836818e5089b23d40196bc7414b7a.
Change-Id: I024bc7f8df7fa65b8b1761f517a99a854de2cec8
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r-- | sources/pyside6/tests/signals/signal_emission_test.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sources/pyside6/tests/signals/signal_emission_test.py b/sources/pyside6/tests/signals/signal_emission_test.py index 769b1839a..b0c02b084 100644 --- a/sources/pyside6/tests/signals/signal_emission_test.py +++ b/sources/pyside6/tests/signals/signal_emission_test.py @@ -15,7 +15,7 @@ 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 QObject, Signal, SIGNAL, QProcess, QTimeLine +from PySide6.QtCore import QObject, Signal, SIGNAL, QProcess, QTimeLine, Slot from helper.usesqapplication import UsesQApplication @@ -45,6 +45,18 @@ class Sender(QObject): dummy_int = Signal(int) +class Receiver(QObject): + '''Receiver class''' + + def __init__(self, p=None): + super().__init__(p) + self.n = 0 + + @Slot(int) + def intSlot(self, n): + self.n = n + + class PythonSignalToCppSlots(UsesQApplication): '''Connect python signals to C++ slots''' @@ -75,6 +87,18 @@ class PythonSignalToCppSlots(UsesQApplication): self.assertEqual(timeline.currentTime(), current + 42) +class ConnectWithContext(UsesQApplication): + '''Test whether a connection with context QObject passes parameters.''' + + def testIt(self): + sender = Sender() + receiver = Receiver() + context = sender + QObject.connect(sender, SIGNAL("dummy_int(int)"), context, receiver.intSlot) + sender.dummy_int.emit(42) + self.assertEqual(receiver.n, 42) + + class CppSignalsToCppSlots(UsesQApplication): '''Connection between C++ slots and signals''' |