Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PySide QTableView currentChanged syntax
QtWS25 Last Chance

PySide QTableView currentChanged syntax

Scheduled Pinned Locked Moved Language Bindings
3 Posts 2 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wab104
    wrote on 23 Nov 2010, 09:36 last edited by
    #1

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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mairas
      wrote on 23 Nov 2010, 10:53 last edited by
      #2

      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

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wab104
        wrote on 23 Nov 2010, 12:01 last edited by
        #3

        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

        1 Reply Last reply
        0

        1/3

        23 Nov 2010, 09:36

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved