[PyQt] problem connecting to QDialog exec_ method

Phil Thompson phil at riverbankcomputing.com
Fri Mar 19 12:56:26 GMT 2010


On Fri, 19 Mar 2010 11:54:36 +0000, Stuart McNicholas
<mcnicholas at ysbl.york.ac.uk> wrote:
> I have a very simple program:
> 
> from PyQt4 import QtGui, QtCore
> import sys
> 
> class Win(QtGui.QWidget):
>    SaveFiles = QtCore.pyqtSignal()
>    def __init__(self,parent=None):
>      QtGui.QWidget.__init__(self,parent)
>      self.fileDialog = QtGui.QDialog()
>      self.SaveFiles.connect(self.fileDialog.exec_)
>      self.SaveFiles.emit()
> 
> app = QtGui.QApplication(sys.argv)
> 
> win = Win()
> win.show()
> win.raise_()
> 
> sys.exit(app.exec_())
> 
> which produces the error:
> 
> Traceback (most recent call last):
>    File "jif.py", line 23, in <module>
>      win = Win()
>    File "jif.py", line 18, in __init__
>      self.SaveFiles.connect(self.fileDialog.exec_)
> TypeError: 'exec_()' has no overload that is compatible with
'SaveFiles()'
> 
> This is with PyQt 4.7.2. The problem is not apparent in 4.7.
> 
> If I subclass QDialog, the problem persists, but I can workaround by 
> defining my own exec_ method.

Yuck - the problem is that it's using the Python method name (exec_) rather
than the C++ method name (exec) to look up the slot.

Attached is a patch that will fix it - looks like there will be a v4.7.3
fairly soon.

Phil
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PyQt-4.7.2.patch
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100319/aa17d72c/attachment.ksh>


More information about the PyQt mailing list