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('currentChanged(QModelIndex, QModelIndex)'), 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??)

  • 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:

  • 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)


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.