Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1902

signals connect method should return Connection object

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.15.2
    • PySide
    • None
    • Windows 10, PySide2 5.15.2.1
    • Windows

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              bluebird75 Philippe Fremy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes