[PyQt] how to get all the signal from a QObject/QWidget ? and other Q about signals

Phil Thompson phil at riverbankcomputing.com
Fri Feb 17 08:51:44 GMT 2012

On Thu, 16 Feb 2012 15:19:18 -0800, Emmanuel Mayssat <emayssat at gmail.com>
> I have a widget inside another widget.
> 1/
> I would like to have a ~for loop that propagate all the signals of the
> inner widget as if they were emitted by the container widget.
> That is for each signals
> self.connect(myChild, SIGNAL("mySignal()"), self.mySignal.emit())

The above line won't work, use...

self.connect(myChild, SIGNAL("mySignal()"), self.mySignal)

> how can I list the signals that an object has?

Use the standard Qt introspection classes starting with QMetaObject or do
a dir() on the class and look for instances of pyqtSignal.

> 2/
> I understand also that the signals needs to be declared at both levels.
> Is there a way to do that progammatically?


> 3/
> A propos, I noticed that inheritance doesn't seem to pass signal
> definition.

What makes you think that?

> That is
> class Lwidget(QWidget):
>     mysignal = pyqtSignal()
> class LSuperWidget(Lwidget):
>     <here the signal needs to be redefined>        <-- is there a way to
> avoid this?

Signals are inherited just like any other class attribute.


More information about the PyQt mailing list