[PyQt] QSignalTransition

Phil Thompson phil at riverbankcomputing.com
Mon Jun 21 09:36:16 BST 2010


On Mon, 21 Jun 2010 09:59:49 +0200, Fx III <fxiiii at gmail.com> wrote:
> Hi all,
> QSignalTransition does not accept signals when come from python extent.
> When I try the following test program I get:
> 
> QSignalTransition: no such signal: Emitter::mySignal()
> 
> this is program
> 
> import PyQt4.QtCore as QtCore
> import PyQt4.QtGui as QtGui
> from pprint import pprint
> 
> class Emitter(QtGui.QPushButton):
>     def __init__(self,parent=None):
>         QtGui.QPushButton.__init__(self,parent)
>        
QtCore.QObject.connect(self,QtCore.SIGNAL("clicked()"),self.emitter)
>     def emitter(self):
>         print "emitting"
>         self.emit(QtCore.SIGNAL("mySignal()"))
> 
> 
> app=QtGui.QApplication([""])
> emitter=Emitter()
> emitter.show()
> machine=QtCore.QStateMachine()
> state1=QtCore.QState(machine)
> state2=QtCore.QState(machine)
> t = QtCore.QSignalTransition(emitter,QtCore.SIGNAL("mySignal()"));
> t.setTargetState(state2);
> state1.addTransition(t);
> QtCore.QObject.connect(state2,QtCore.SIGNAL("entered()"),
> 
>  lambda:pprint("ENTERED!!!"))
> machine.setInitialState(state1)
> machine.start()
> app.exec_()

You haven't defined the signal. Add...

    mySignal = pyqtSignal()

..to the definition of Emitter.

Phil


More information about the PyQt mailing list