The proper use of QSignalMapper

David Boddie david at
Wed Jan 17 16:51:40 CET 2007

borntonetwork wrote:

> I am trying to implement QTCore.QSignalMapper using PyQT. I finally got
> to a point where I don't receive any compile or runtime error messages,
> but I also do not see the final slot function fire off. Here is a
> snippet of the code:
>         self.signalMapper = QtCore.QSignalMapper(window)
>         # Use qsignalmapper to use of one slot function for multiple
>         # widgets. The map() function sends the slot an extra param
>         # that identifies the sender.
>         for idx in range(1, maxIngredients+1):
>             wName = 'chkProductIngredientsDelete_'+str(idx)
>             w = self.__dict__[wName]
>   , QtCore.SIGNAL("stateChanged(int)"),
>                 self.signalMapper,
>                 QtCore.SLOT(""))

You need to pass the C++ signature to the SLOT() function. I believe
you want the form that does not accept any arguments:

   , QtCore.SIGNAL("stateChanged(int)"),

Alternatively, you can pass the slot directly to the function:

   , QtCore.SIGNAL("stateChanged(int)"),

PyQt accepts Python methods as slots, without requiring that they be
wrapped in calls to SLOT().


More information about the Python-list mailing list