-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
signal.connect() TypeError in pyqt5 when signal has an argument #388
Comments
I don't think the os matters, but this was on a Mac. And the pip environments I tested with are:
vs.
|
Thanks for reporting this. Does this happen when using PyQt5 directly, without Qt.py? Could this be a PyQt5 bug, rather than a Qt.py bug? |
Looks like PyQt5 requires inheriting from - class Runner(object):
+ class Runner(QtCore.QObject):
def __init__(self, wind):
+ super().__init__()
wind.willclose.connect(self.didclose)
self._wind = wind Looks like this is not a Qt.py issue but a low level difference in how PySide2 and PyQt5 work. I wonder if there are any |
Nice catch; yes I expected PySide to require this too. This is true for the C++ side too, so I would consider PySide to be at fault for allowing it. Is there anything Qt.py can do to disallow it cross binding? (thinking) That could help users get the error early and on every binding. |
@MHendricks thanks! I had tested it with QObject but I forgot to initialize it, so I thought it didn't matter in that case. It makes sense that it should require QObject, so I agree it's more Pyside's fault. |
@mottosso I think there should be some decorator magic that could examine the mro of the class of the unbound method and see if it inherits from QObject? If I can come up with anything I'll share |
Great, then let's consider this issue fixed once we can prevent PySide from allowing signals in non-QObject classes. |
I've found another inconsistency when creating a >>> from PySide2 import QtWidgets
>>> QtWidgets.QApplication()
<PySide2.QtWidgets.QApplication(0x23563d1ecc0) at 0x000002353342A0F0>
>>> exit() >>> from PyQt5 import QtWidgets
>>> QtWidgets.QApplication()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: QApplication(argv: List[str]): not enough arguments
>>> QtWidgets.QApplication([])
<PyQt5.QtWidgets.QApplication object at 0x00000264E3274160> |
Sounds like a good fit for another issue with a dedicated PR. I'd vouch to make PyQt5 be OK with no argument, by just subclassing it with our own wrapper. Up for it? |
Using this code example:
produces a TypeError when trying to connect a signal using python3 & PyQt5:
TypeError: connect() failed between MainWind.willclose[int] and didclose()
However, the same code runs fine using python3 & PySide2.
An undecorated didclose() method will also run using PyQt5, and a slot method that takes no arguments will also run.
The text was updated successfully, but these errors were encountered: