在PySide2中使用invokeMethod时QGenericArgument/Q_ARG的用法

2024-04-20 12:46:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将代码从PyQt5移植到PySide2。在某种程度上,我使用的是:

QMetaObject.invokeMethod(dialog, "my_function", Qt.QueuedConnection, QGenericArgument.Q_ARG(str, filepath))

然而,Q峈ARG不在PySide2中的QGenericArgument中。事实上,在文档中并没有描述它是通用的。在

计划B:我尝试直接使用QGenericArgument,即使文档不鼓励这样做。因此,我尝试了这些:

^{pr2}$

在所有情况下,错误都是相同的:

ERROR: 'PySide2.QtCore.QGenericArgument' called with wrong argument types:
PySide2.QtCore.QGenericArgument(str, str)
Supported signatures:
PySide2.QtCore.QGenericArgument(PySide2.QtCore.QGenericArgument)
PySide2.QtCore.QGenericArgument(bytes = nullptr, void = nullptr)

看来我必须在这里使用指针,但不知道怎么做。另外,我还没有找到PySide2的invokeMethod示例。在

有什么想法吗?在


Tags: 代码文档myargfunctionqtpyqt5dialog