@mjs513
That pyqtSignal(...) is a PyQt-ism. I think you have to use it any time you want to define your own signal.
However, none of this relates to your earlier problem of
self.connect(self.serialPortEdit, SIGNAL("returnPressed()"), self.connectButton, SIGNAL("clicked()"))
I have now had a chance to try this. On my PyQt 5.15.6 the equivalent of the attempted
self.serialPortEdit.returnPressed.connect(self.connectButton.clicked)
gives an error message like yours but with a bit more detail:
QObject::connect: Incompatible sender/receiver arguments
QLineEdit::returnPressed() --> QPushButton::clicked(bool)
Traceback (most recent call last):
File "/home/jon/PyQt5/testconnect1.py", line 20, in <module>
window()
File "/home/jon/PyQt5/testconnect1.py", line 14, in window
le.returnPressed.connect(pb.clicked)
TypeError: connect() failed between returnPressed() and clicked()
You can see from QLineEdit::returnPressed() --> QPushButton::clicked(bool) it is saying returnPressed() takes no argument but QPushButton::clicked(bool) does (a bool for whether any checkbox on the button is checked). Which is what I assumed the problem would be. Although this defaults to False if not passed, it is still enough to make those two signals' signatures incompatible, you cannot directly get returnPressed() signal to call clicked(bool).
In principle this is where you would use the lambda syntax I mentioned for the slot, like one of these:
self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked() )
self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked(False) )
But this results in
le.returnPressed.connect(lambda: pb.clicked())
TypeError: native Qt signal is not callable
PyQt apparently does not like us directly calling QPushButton.clicked(), because it is a "native Qt signal". We would be allowed to do this in C++. I don't know how you would get to call it from PyQt. [Following is unnecessary, see UPDATE section below.]
The only way I know to do this now would be:
self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.click() )
I still use a lambda, but I call QPushButton.click() which is a slot to "emulate" a click rather than calling the QPushButton.clicked() signal which Qt emits. In this case I could also skip the lambda (because their arguments --- none --- are compatible) and attach this slot directly to the signal:
self.serialPortEdit.returnPressed.connect( self.connectButton.click )
UPDATE
OK, I get why, PyQt5 never lets you call a signal method directly, you always have to use emit(). So to use clicked() signal directly and not have to use the click() slot (which we are lucky even exists), you should use:
self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked.emit() )