Skip to main content
 首页 » 编程设计

python之不支持 C++ 类型槽参数

2025年05月04日18yjmyzz

我试图发出一个信号并发送两个参数,一个是 Song 对象的列表,第二个是一个 QtGui.QTableView 对象。

我试过这样做:

self.emit(QtCore.SIGNAL("searchOutput(list, QtGui.QTableView)"), songsObjs, self.table) 

但是我得到以下错误:

TypeError: C++ type 'list' is not supported as a slot argument type 

我能做什么?

请您参考如下方法:

如果您查看 reference然后它说

It is possible to pass any Python object as a signal argument by specifying PyQt_PyObject as the type of the argument in the signature.

和

While this would normally be used for passing objects like lists and dictionaries as signal arguments, it can be used for any Python type.

所以尝试这样做:

self.emit(QtCore.SIGNAL("searchOutput(PyQt_PyObject, QtGui.QTableView)"), songsObjs, self.table)