The proper use of QSignalMapper

David Boddie david at boddie.org.uk
Thu Jan 18 10:59:07 EST 2007


borntonetwork wrote:
> Thanks, David, for you help.
>
> When I change the slot function to what you show in your second
> example, I get the same results: nothing.

This may be due to something I missed in your code. When you
connect the signal from the signal mapper to your class, you
need to specify the signal as a C++ signature as well:

        self.connect(self.signalMapper, QtCore.SIGNAL(
             "mapped(int)"),
             self.deleteProductIngredient)

The second example should now work.

Looking at the first example, which uses SLOT() rather than specifying
a Python method, the following might be due to the way you call
connect, though it is surprising:

> When I change it to what you
> have in your first example, I get the following:
>
> Object::connect: No such slot QApplication::map()
> Object::connect:  (sender name:   'chkProductIngredientsDelete_1')
> Object::connect:  (receiver name: 'main.py')

[...]

It looks like you should try something like this:

             self.connect(w, QtCore.SIGNAL("stateChanged(int)"),
                  self.signalMapper,
                  QtCore.SLOT("map()"))

I can't understand why calling self.app.connect() would cause the
connection to be attempted between self.signalMapper and self.app.

Maybe someone on the PyQt/PyKDE mailing list would be able to
explain the behaviour you're seeing:

  http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

David




More information about the Python-list mailing list