TypeError: 'PySide2.QtCore.QObject.connect' called with wrong argument types: PySide2.QtCore.QObject.connect(QPushButton, str, QPushButton) Supported signatures: PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, bytes, typing.Callable, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QObject.connect(bytes, typing.Callable, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QObject.connect(bytes, PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, bytes, bytes, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) 进程已结束,退出代码为 1
时间: 2024-03-07 21:49:43 浏览: 320
Vue 报错TypeError: this.$set is not a function 的解决方法
5星 · 资源好评率100%
这个错误信息是因为您在使用 PySide2 连接信号和槽时,传入的参数不正确。通常,PySide2.QtCore.QObject.connect() 方法需要传入 4 个参数,分别是信号源、信号、槽源和槽。
比如说,如果您要将 QPushButton 的 clicked 信号连接到另一个 QPushButton 的 clicked 槽,可以这样写:
```python
from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton
app = QApplication([])
window = QMainWindow()
button1 = QPushButton("Button 1")
button2 = QPushButton("Button 2")
# 将 button1 的 clicked 信号连接到 button2 的 clicked 槽
button1.clicked.connect(button2.clicked)
window.setCentralWidget(button1)
window.show()
app.exec_()
```
请仔细检查您的代码,确保传入的参数与上述格式一致。如果问题仍然存在,请提供更多代码和上下文信息,以便我们更好地帮助您解决问题。
阅读全文