[PyQt] New style signal connect not working

Alan Ezust alan.ezust at gmail.com
Thu Feb 5 19:45:22 GMT 2015


Perhaps adding a @pyqtSlot(QModelIndex,QModelIndex) above the function def
will help?


On Thu, Feb 5, 2015 at 11:16 AM, Tony Arnold <tony.arnold at manchester.ac.uk>
wrote:

> I have an application with a QTableView and I am trying to connect the
> currentRowChanged signal to a slot. When I use the old style, it works,
> but the newer style does not.
>
> Here is the code to connect the signal using the old style:
>
> self.connect(self.competitionView.selectionModel(),
>                   SIGNAL("currentRowChanged(QModelIndex,QModelIndex)"),
>                     self.competitionChanged)
>
> and the slot is defined as:
>
>     def competitionChanged(self, index):
>
> This works fine.
>
> But if I connect the signal with the preferred new style so:
>
>
> self.competitionView.selectionModel().currentRowChanged.connect(self.competitionChanged)
>
> Then an exception gets raised when the slot gets called. I get the
> following error:
>
> The debugged program raised the exception unhandled TypeError
> "competitionChanged() missing 1 required positional argument: 'index'"
>
> I am using PyQt4 and python 3.4 with Qt 4.8.6
>
> Any suggestions where I might be going wrong?
>
> Regards,
> Tony.
> --
> Tony Arnold, IT Security Analyst, University of Manchester.
> T: +44 (0) 161 275 6093, F: +44 (0) 705 344 3082,
> M: +44 (0) 773 330 0039, E: tony.arnold at manchester.ac.uk
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150205/4ab33985/attachment.html>


More information about the PyQt mailing list