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

Connecting QMetaMethods fails, seems to resolve to the wrong overload

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.9.0, 6.8.3
    • 5.14.1
    • PySide
    • None
    • ad70c1a75 (dev), a8013eb52 (6.8)

      See the following snippet.
      When printing available signatures for QtObject.connect, one takes two QObjects along with two QMetaMethods.
      When calling QtObject.connect with such arguments, we get

      TypeError: Use the function PySide2.QtCore.SIGNAL on signals
      

      which is the error we'd get when calling QtObject.connect with str attributes that are not well formatted. It seems like connect got resolved to that wrong overload.

      >>> from PySide2 import QtCore, QtWidgets
      >>> app = QtWidgets.QApplication([])
      >>> l1 = QtWidgets.QLineEdit("One")
      >>> l2 = QtWidgets.QLineEdit("Two")
      >>> signal = l1.metaObject().method(l1.metaObject().indexOfSignal("textChanged(QString)"))
      >>> slot = l2.metaObject().method(l2.metaObject().indexOfSlot("setText(QString)"))
      >>> 
      >>> QtCore.QObject.connect("Please", "print", "supported", "signatures")
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: 'PySide2.QtCore.QObject.connect' called with wrong argument types:
        PySide2.QtCore.QObject.connect(str, str, str, str)
      Supported signatures:
        PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, typing.Callable, PySide2.QtCore.Qt.ConnectionType=PySide2.QtCore.Qt.ConnectionType.AutoConnection)
        PySide2.QtCore.QObject.connect(str, typing.Callable, PySide2.QtCore.Qt.ConnectionType=PySide2.QtCore.Qt.ConnectionType.AutoConnection)
        PySide2.QtCore.QObject.connect(str, PySide2.QtCore.QObject, str, 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, str, str, PySide2.QtCore.Qt.ConnectionType=PySide2.QtCore.Qt.ConnectionType.AutoConnection)
        PySide2.QtCore.QObject.connect(PySide2.QtCore.QObject, str, PySide2.QtCore.QObject, str, PySide2.QtCore.Qt.ConnectionType=PySide2.QtCore.Qt.ConnectionType.AutoConnection)
      >>>
      >>> # Making sure we can use the 4th signature
      >>> l1.__class__.mro()
      [<class 'PySide2.QtWidgets.QLineEdit'>, <class 'PySide2.QtWidgets.QWidget'>, <class 'PySide2.QtCore.QObject'>, <class 'PySide2.QtGui.QPaintDevice'>, <class 'Shiboken.Object'>, <type 'object'>]
      >>> l2.__class__.mro()
      [<class 'PySide2.QtWidgets.QLineEdit'>, <class 'PySide2.QtWidgets.QWidget'>, <class 'PySide2.QtCore.QObject'>, <class 'PySide2.QtGui.QPaintDevice'>, <class 'Shiboken.Object'>, <type 'object'>]
      >>> 
      >>> signal.__class__.mro()
      [<class 'PySide2.QtCore.QMetaMethod'>, <class 'Shiboken.Object'>, <type 'object'>]
      >>> slot.__class__.mro()
      [<class 'PySide2.QtCore.QMetaMethod'>, <class 'Shiboken.Object'>, <type 'object'>]
      >>> 
      >>> # Two QMetaMethods, two QObject subclasses
      >>> QtCore.QObject.connect(l1, signal, l2, slot)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: Use the function PySide2.QtCore.SIGNAL on signals
      

        1. pyside1277.py
          0.6 kB
          Friedemann Kleint
        For Gerrit Dashboard: PYSIDE-1277
        # Subject Branch Project Status CR V

            kleint Friedemann Kleint
            ilmantoine Antoine ILM
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change