November 23, 2010

Wayne Boucher Wayne Boucher
Lab Rat
1 posts

PySide QTableView currentChanged syntax

 

In PySide I have a table (QTableView). I would like a specific function called when someone selects a row/cell in the table. I assume that the currentChanged() signal is supposed to accomplish this. I tried:

self.connect(self, QtCore.SIGNAL’), selectCallback)

and other variants on specifying the argument types, and nothing seems to work. So is currentChanged() not what I think it is for or, if it is, what should the correct syntax be? (I don’t use and have never used Qt, just PySide.) (The “new” version of the connect syntax seems to be no better, you still have to specify the argument types, correct??)

2 replies

November 23, 2010

mairas mairas
Ant Farmer
22 posts

Hi,

I think currentChanged should do want you want. However, the forum appears to have botched your example syntax so it’s difficult to see what’s going on.

One immediate suggestion, however, is to use the new-style signal/slot syntax because it does a bit better job of catching some types of errors than the old syntax:

http://developer.qt.nokia.com/wiki/Signals_and_Slots_in_PySide
http://www.pyside.org/docs/pseps/psep-0100.html

November 23, 2010

Wayne Boucher Wayne Boucher
Lab Rat
1 posts

Hmm, the preview worked ok but evidently something decided to trash half of that line of code. Anyway, I’ve tried the new form for slots. This does indeed look better in that at least it is a real type that you need to specify for the arguments rather than a string. So I have a subclass of QTableView, and in that I now have:

from PySide import QtCore # well, this is at the top of the module

self.currentChanged(QtCore.QModelIndex, QtCore.QModelIndex).connect(selectCallback)

And now I am getting the error (which does not look good!):

TypeError: ‘PySide.QtGui.QTableView.currentChanged’ called with wrong argument types: PySide.QtGui.QTableView.currentChanged(Shiboken.BaseWrapperType, Shiboken.BaseWrapperType)
Supported signatures: PySide.QtGui.QTableView.currentChanged(PySide.QtCore.QModelIndex, PySide.QtCore.QModelIndex)

Wayne

 
  ‹‹ Ask Help from beginner      PySide compared to PyQt4 : problem with QImage __init__() ››

You must log in to post a reply. Not a member yet? Register here!