通过 QtGui.QAction 将参数传递给触发的方法

Posted

技术标签:

【中文标题】通过 QtGui.QAction 将参数传递给触发的方法【英文标题】:Passing arguments through QtGui.QAction to the triggered method 【发布时间】:2013-01-12 12:27:18 【问题描述】:

假设我有一个类似的方法:

def open(self, opt):
    if opt == True:
    ...
    if opt == False:
    ...

如何使用 QtGui.QAction 将参数传递给它,例如:

self.openAct = QtGui.QAction("O&pen", self, shortcut="Ctrl+O",
            statusTip="Opens a location", triggered=self.open)

【问题讨论】:

【参考方案1】:

我找到答案是from functools import partial。它在This thread。

【讨论】:

以上是关于通过 QtGui.QAction 将参数传递给触发的方法的主要内容,如果未能解决你的问题,请参考以下文章