I'm trying to find a way to get the signature of a bound SignalInstance
in PySide.
Take the following example:
from PySide2.QtCore import Signal, QObject
class MyObj(QObject):
some_signal = Signal(int)
obj = MyObj()
sig_instance = obj.some_signal
I can get to the signature of some_signal
if I have a pointer to obj
or MyObj
itself, with obj.metaObject().method(5).methodSignature()
... but what if I only had a pointer to sig_instance
?
In C, the SignalInstance
keeps the signature in a private struct PySideSignalInstancePrivate
(here) ... but after a log of digging, I've been unable to come up with a way to recover that signature given only the python SignalInstance
tips?
update:
If it's genuinely not possible without access to the metaObject on obj
itself. I have this stupid solution... but still would love to know if there's a better way.
try:
sig_instance.emit(*(1,) * 50) # emit with ridiculous args
except TypeError as e:
print(str(e).split(' only accepts')[0]) # parse err
I'll also note that a PyQt5.QtCore.pyqtBoundSignal
does have an attribute .signal
that holds the string form of the signature