【发布时间】:2022-01-09 04:14:36
【问题描述】:
我正在从以下位置移植应用程序: python 3.8.5 / PyQt5,到: python 3.10.0 / PySide6
此代码在上下文菜单中添加了多个 QAction,并与 python 3.8.5 / PyQt5 一起使用:
for filepath in filepaths:
action = QtGui.QAction(QtGui.QIcon('icon.png'), filepath, self)
action.triggered.connect(lambda checked, path=filepath: self.open_file(path))
menu.addAction(action)
但是使用 python 3.10.0 / PySide6,当我点击 QAction 时出现此错误:
menu.<locals>.<lambda>() missing 1 required positional argument: 'checked'
我不确定它是来自 python 升级还是 PyQt5 => PySide6 更改?
在 lambda 中保留文件路径值的副本的任何解决方法?
【问题讨论】: