[PyQt] Incompotible signatures
Hans-Peter Jansen
hpj at urpla.net
Wed Oct 20 13:26:26 BST 2010
On Wednesday 20 October 2010, 12:23:36 Alexandr N Zamaraev wrote:
> I upgrade my Kubuntu to 10.10.
> (libqtcore4 v4.7.0-0ubuntu4, python-sip v4.10.5-0ubuntu1, python-qt4
> v4.7.4-0ubuntu1)
> And I receive TypeError for my projects
>
> Sample code (file slots.py):
> #! /usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import sys
> from PyQt4 import QtCore, QtGui
>
> class TableView(QtGui.QTableView):
> def __init__(self):
> super(TableView, self).__init__()
> self.doubleClicked.connect(self.noSlot)
> self.doubleClicked.connect(self.cppSlot)
> self.doubleClicked.connect(self.pySlot)
>
> def noSlot(self, index):
> pass
>
> @QtCore.pyqtSlot('const QModelIndex&')
> def cppSlot(self, index):
> pass
>
> @QtCore.pyqtSlot(QtCore.QModelIndex)
> def pySlot(self, index):
> pass
>
> def main():
> app = QtGui.QApplication(sys.argv)
> TableView()
>
> if __name__ == '__main__':
> main()
>
> Console session:
> $ ./slots.py
> Traceback (most recent call last):
> File "./slots.py", line 30, in <module>
> main()
> File "./slots.py", line 27, in main
> TableView()
> File "./slots.py", line 12, in __init__
> self.doubleClicked.connect(self.pySlot)
> TypeError: pySlot() has no overload that is compatible with
> doubleClicked(QModelIndex)
FWIW, it does not traceback with current sip/PyQt (snapshots) at least.
There an optional signal dict key argument, that might help you to work
around the issue. See the Bar class in:
http://www.riverbankcomputing.com/static/Docs/PyQt4/pyqt4ref.html#connecting-disconnecting-and-emitting-signals
Hth,
Pete
More information about the PyQt
mailing list