[PyQt] need help with new signals

Phil Thompson phil at riverbankcomputing.com
Wed Oct 24 17:49:29 BST 2012


On Tue, 23 Oct 2012 22:30:12 +0100, Matthew Ngaha <chigga101 at gmail.com>
wrote:
> im trying to figure out how i can change the old signal syntax to new.
the
> program im reading through creates a widget that inherits from QSpinBox.
> 
> zerospinbox = ZeroSpinBox()
> 
> It then emits its custom signal, then that signal is connected to a
python
> method.  Here are the 2 codes i need help converting.
> 
> self.emit(SIGNAL("atzero"), self.zeros)       #this is zerospinbox
emitting
> a custom "atzero" signal
> 
> self.connect(zerospinbox, SIGNAL("atzero"), self.announce)        #and
here
> is the same signal being connected to a python method.

The above code doesn't look right - "atzero" is not a proper signature.

> As you can see this code example uses the old style syntax, can anyone
> please convert it for me into the newer style syntax.

Assuming atzero has been defined properly with pyqtSignal(), then to
emit...

    self.atzero.emit(self.zeros)

...and connect...

    zerospinbox.atzero.connect(self.announce)

Phil


More information about the PyQt mailing list