On Fri, 19 Mar 2010 11:54:36 +0000, Stuart McNicholas
<[email protected]> 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
diff -r 9528814bc9bd qpy/QtCore/qpycore_pyqtboundsignal.cpp
--- a/qpy/QtCore/qpycore_pyqtboundsignal.cpp    Wed Mar 17 18:26:22 2010 +0000
+++ b/qpy/QtCore/qpycore_pyqtboundsignal.cpp    Fri Mar 19 12:52:03 2010 +0000
@@ -561,6 +561,13 @@
     {
         rx_self = PyCFunction_GET_SELF(slot_obj);
         rx_name = ((PyCFunctionObject *)slot_obj)->m_ml->ml_name;
+
+        // We actually want the C++ name which may (in theory) be completely
+        // different.  However this will cope with the exec_ case which is
+        // probably good enough.
+        if (rx_name.endsWith('_'))
+            rx_name.chop(1);
+
         need_qt_slot = true;
     }
     else
_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to