[PyQt] New style signal connect not working
Tony Arnold
tony.arnold at manchester.ac.uk
Thu Feb 5 20:14:23 GMT 2015
Alan,
On 05/02/15 19:45, Alan Ezust wrote:
> Perhaps adding a @pyqtSlot(QModelIndex,QModelIndex) above the function
> def will help?
Thanks. Exactly what I needed. Now works perfectly!
> On Thu, Feb 5, 2015 at 11:16 AM, Tony Arnold
> <tony.arnold at manchester.ac.uk <mailto: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
More information about the PyQt
mailing list