[PySide] PySide QSignalMapper not working

Jonathan Steele jsteele at cert.org
Fri Nov 1 16:19:56 CET 2013


Hedieh,

If I've understood correctly from your previous mails, the basic problem
you are trying to solve is how to create a handler function that can be
called with different arguments, depending on which widget is triggered.
Is that correct?  If so, I found this page a very useful resource that
covers the different methods available:
http://www.blog.pythonlibrary.org/2013/04/10/pyside-connecting-multiple-wid
gets-to-the-same-slot/

Which method you use probably comes down to personal preference, but in a
similar situation with my application I used the lambda method.  For
example, here's the line that connects the signal to my handler:

clearaction.triggered.connect(lambda col=colnum: self.OnClearMap(col))

In this example I'm connecting the QAction from a menu item to an
anonymous function that simply grabs a variable ("colnum) and passes it
through to my handler, which is just a regular old method in the same
class.  You should be able to do something similar for your pushbuttons.
If you don't like the lambda method you can see some other options in the
link I gave above.

Hope this helps.

--Jon




More information about the PySide mailing list