PySide6, Python 3.10 : Issue with Signal.emit only sending one argument :
-
I have a Signal defined as a class variable in a custom class :
Reset_needed = QtCore.Signal(str,str)and I emit as follows :
self.Reset_needed.emit(name, connection_id)Where both
nameandconnection_idare both non-empty strings.In another class I have connected to the above signal and the handler takes two arguments :
nameandcidWithin the handler
nameis entirely as expected,, but thecidargument is received as an empty string (ie. only the first argument to emit is used).
Is this a known issue ? -
I have managed to identify the issue, and it was a problem deep in my code (not in QT thankfully). In my case everything i had done had lead me to believe that both parameters were strings, but in fact the 2nd parameter
cidis in fact an integer, which means that QT type mangling would not have correctly used the str type for it when defining the signal - an easy fix for me.Ty to @SGaist for trying to help solve this - it turns out to be a classic PEBCAK error - and the first time in 8 years I have been hit with a real Python type issue (thankfully not in production.
-
Hi,
Which version of PySide are you using ?
Did you decorate the target method with Slot ?
Please provide a minimal runnable script that shows this issue. -
Hi,
Which version of PySide are you using ?
Did you decorate the target method with Slot ?
Please provide a minimal runnable script that shows this issue.@SGaist
I am using PySide6.None of the examples I have seen use any sort of decorator on the target function: I will try that.
I am trying to trim the whole thing into a small example - I will post it as soon as I have it.
Bizzarely the mininum example works fine, and i can't see the difference between the example and the full version.
import sys from PySide6 import QtCore from PySide6.QtWidgets import QApplication, QWidget class Terminal(QtCore.QObject): ResetNeeded = QtCore.Signal(str, str) def __init__(self, name, cid): super().__init__() self._name = name self._cid = cid def trigger(self): self.ResetNeeded.emit(self._name, self._cid) class Application(QWidget): def __init__(self): super().__init__() self._t1 = Terminal('Production','2363') self._t2 = Terminal('Test','7369') self._t1.ResetNeeded.connect(self.triggered) self._t2.ResetNeeded.connect(self.triggered) self.process() def triggered(self, name, cid): print(f'{name!r} {cid!r}') def process(self): self._t1.trigger() self._t2.trigger() if __name__ == '__main__': app = QApplication() w = Application() w.show() sys.exit(app.exec())The only difference I can see is that in the full version the 'Application' class is not a main window - but is embedded into another window.
-
I have managed to identify the issue, and it was a problem deep in my code (not in QT thankfully). In my case everything i had done had lead me to believe that both parameters were strings, but in fact the 2nd parameter
cidis in fact an integer, which means that QT type mangling would not have correctly used the str type for it when defining the signal - an easy fix for me.Ty to @SGaist for trying to help solve this - it turns out to be a classic PEBCAK error - and the first time in 8 years I have been hit with a real Python type issue (thankfully not in production.
-
T TonySuffolk has marked this topic as solved on
-
Glad you found out and thanks for sharing !
Didn't you get a warning for that mismatch at some point ?