[PyQt] problem connecting to QDialog exec_ method

Stuart McNicholas mcnicholas at ysbl.york.ac.uk
Fri Mar 19 11:54:36 GMT 2010


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.

Best Wishes,
Stuart McNicholas


More information about the PyQt mailing list