[PyKDE] Emitting a signal from Python

Tony Cappellini cappy2112 at gmail.com
Mon Feb 12 06:21:56 GMT 2007


Perhaps I'm going about this wrong. I want to simulate the user
selecting the first item (Or any item) in a combo box.

I don't need to pass it a text string, the strings are already in the
combo box. I just need to select it, so the signal I've connected to
the combo box activate signal gets fires off to the slot.


> > When I try using the combo box
> >
> > self.Names.emit(QtCore.SIGNAL("activated()"))
> >
> > the desired result doesn't occur. That is, the TextEdit never receives
> > the signal.
>
> You need to use exactly the same signal name - in this case you connected
> the combo box's signal to a Python slot with
>
>   self.connect(self.Names, QtCore.SIGNAL("activated(const QString &)"),
>                self.updateNameBrowser)
>
> so you want to use emit the activated(const QString &) signal. Since this
> signal has a parameter (const QString &), you need to pass an argument to
> the emit() method:
>
>   self.Names.emit(QtCore.SIGNAL("activated(const QString &)"), text)
>
> where text is some string value.
>
> Although you can get away without using SLOT() in Python, and thereby avoid
> dealing with C++ type signatures, it's easy to forget that you have to be
> explicit when dealing with SIGNAL().




More information about the PyQt mailing list