[PyQt] QPushbutton connect(no-arg) signal variant in 5.3?

Phil Thompson phil at riverbankcomputing.com
Sun Sep 7 17:45:10 BST 2014


On 06/09/2014 7:03 pm, David Cortesi wrote:
> Python 3.3. Under version 5.2 the program below prints,
> 
>> PyQt 5.2 Qt 5.2.0
>> slot got ()  # <-- when button is clicked
> 
> Under version 5.3, it prints
> 
>> PyQt 5.3 Qt 5.3.0
>> 'there is no matching overloaded signal'
> 
> So it appears that the syntax "clicked[()].connect(slot)" to select the
> no-arg signal, that worked in 5.2, somehow does not in 5.3. Apologies 
> if
> this is fixed in 5.3.1, however I don't see anything relevant in the 
> 5.3.1
> changelog.
> 
> Here is the quite simple test case:
> 
>> '''
>> Test of QPushButton clicked() signal
>> ''
>> from PyQt5.QtCore import PYQT_VERSION_STR
>> from PyQt5.QtCore import QT_VERSION_STR
>> print('PyQt',PYQT_VERSION_STR,'Qt',QT_VERSION_STR)
>> 
>> from PyQt5.QtWidgets import QApplication,QWidget,QPushButton
>> def slot(*args):
>>     print('slot got',args)
>> the_app = QApplication([])
>> widg = QWidget()
>> pb = QPushButton(widg)
>> try:
>>     pb.clicked[()].connect(slot)
>> except KeyError as k:
>>     print(k)
>>     exit()
>> widg.show()
>> the_app.exec_()

This is intended and documented - but I forgot to document it as a 
potential incompatibility in PyQt v5.3.

The original design was broken and I felt it was a safe change because I 
can't see why you would ever need to do this. Just using 
clicked.connect() should work for all versions.

Happy to discuss further if you disagree.

Phil


More information about the PyQt mailing list