[PyQt] signal/slot with parameter (QSignalTransition)

Thiago Zanetti thiago.project at gmail.com
Thu Apr 15 02:41:52 BST 2010


2010/4/14 Philippe Crave <philippe.crave at gmail.com>

> Hi,
>
> in a class, I have a QStateMachine, with some QState.
> I would like to make a targetless transition for one state.
> I followed the documentation here
> http://qt.nokia.com/doc/4.6/statemachine-api.html#targetless-transitions
>
> it works well if the initial event that launch the targetless transition
> does not include any variables.
> but now, I emit an event with an increment from a wheelEvent.
> self.emit(SIGNAL("wheelEvent(int)"), inc)
> I do not know how to propagate that value from that event to the target
> slot function self.change_drive.
>
> actually, I get this error message:
> TypeError: change_drive() takes exactly 2 arguments (1 given)
>
> here is a part of my class
> ...
> t = QSignalTransition(self, SIGNAL("wheelEvent(int)"))
> self.state_in.addTransition(t)
> self.connect(t, SIGNAL("triggered()"), self.change_drive)
>
> @pyqtSignature("int")
> def change_drive(self, v):
>     print 'change_drive', v
>
> def wheelEvent(self, e):
>     inc = cmp(e.delta(), 0) * -1
>     self.emit(SIGNAL("wheelEvent(int)"), inc)
>
> thank you
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


I think this is happening because the "triggered()" signal doesn't emit any
argument. So, the callback is not receiveing any argument but the "self"
argument. Probably that is the reason.

I hope this helps you.

Regards,
Thiago Zanetti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100414/8ddaf1b7/attachment.html>


More information about the PyQt mailing list