Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.15.2
-
None
-
Windows 10, PySide2 5.15.2.1
Description
This affects PySide2.
In C++, when connecting a signal to a slot, the connect() call will return a QMetaObject::Connection object. This object can further be used if you want to disconnect the created connection. See https://doc.qt.io/qt-5/qobject.html#connect
However, in PySide2, this does not work. connect() returns a bool:
>>> from PySide2.QtCore import QProcess, QCoreApplication
>>> app = QCoreApplication([])
>>> p = QProcess()
>>> def slot1(): print('slot1')
...
>>> p.readyRead.connect(slot1)
True
>>> p.disconnect(slot1)
Traceback (most recent call last):
{{ File "<stdin>", line 1, in <module>}}
TypeError: 'PySide2.QtCore.QObject.disconnect' called with wrong argument types:
{{ PySide2.QtCore.QObject.disconnect(function)}}
Supported signatures:
{{ PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QMetaObject.Connection)}}
{{ PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, bytes, typing.Callable)}}
{{ PySide2.QtCore.QObject.disconnect(bytes, typing.Callable)}}
{{ PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, typing.Union[bytes, NoneType] = None)}}
{{ PySide2.QtCore.QObject.disconnect(bytes, PySide2.QtCore.QObject, bytes)}}
{{ PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod, PySide2.QtCore.QObject, PySide2.QtCore.QMetaMethod)}}
{{ PySide2.QtCore.QObject.disconnect(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QObject, bytes)}}
Note that this works correctly in PyQt5.
Attachments
Issue Links
- duplicates
-
PYSIDE-1334 Return QMetaObject.Connection from SignalInstance.connect()
- Closed