diff options
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''' |