Details
Description
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
Attachments
For Gerrit Dashboard: PYSIDE-1277 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
299014,1 | WIP: Use QMetaMethod overload for QObject.connect | 5.14 | pyside/pyside-setup | Status: NEW | -2 | 0 |