Connect Function In Pyqt5 Does Not Work
I recently moved from pyside to pyqt5 and there is a problem. I looked it up online and apparently, it already happened to people who used pyqt4 and moved to pyqt5. However, it did
Solution 1:
connect(slot[, type=PyQt5.QtCore.Qt.AutoConnection[, no_receiver_check=False]])
Connect a signal to a slot. An exception will be raised if the connection failed. Parameters:
slot
– the slot to connect to, either a Python callable or another bound signal.type
– the type of the connection to make.no_receiver_check
– suppress the check that the underlying C++ receiver instance still exists and deliver the signal anyway.
for your example:
self.buttonBox.accepted.connect(Dialog.accept) # pyqt5
QtCore.QObject.connect(self.buttonBox.rejected, Dialog.reject) # pyqt4
As a sidenote, "Dialog" sounds like a class, you probably want to connect to an instance, else think about naming your instances with lowercase front-letters ...
Post a Comment for "Connect Function In Pyqt5 Does Not Work"