How to pass arguments to callback functions in PyQt

后端 未结 5 1511
臣服心动
臣服心动 2020-11-30 10:21

I have around 10 QAction (this number will vary in runtime) in a toolbar, which all will do same thing, but using different parameters. I am thinking to add parameter as an

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 10:51

    There is still a bug in the way PyQt uses QSignalMapper. I discovered a work-around here:

    http://www.riverbankcomputing.com/pipermail/pyqt/2010-March/026113.html

    To fix the answered question make the following change:

            action.triggered[()].connect(self.mapper.map)
    

    This was needed for the following version of Python:

    Python 2.6.6 (r266:84292, Feb 21 2013, 19:26:11)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
    

提交回复
热议问题