[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Re: QTableView selected item signals via QItemSelectionModel
From:       Alberto Berti <alberto () metapensiero ! it>
Date:       2008-11-19 22:15:54
Message-ID: 87ljvfpdk5.fsf () metapensiero ! it
[Download RAW message or body]

> > > > > "Scott" == Scott Frankel <frankel@circlesfx.com> writes:

    Scott> Hello,

    Scott> What's the proper way to identify which row of a QTableView
    Scott> instance a user may have selected?

The use of the QItemSelectionModel seems the right approach to me. The
problem is then to identify what you really need, because the selection
model carries both the information of the "current" ModelIndex which has
user input focus AND the possible list of ModelIndexes (read cells)
highlighted to be the subject of the next operation. Using
'selectionChanged' helps when latter is the needed information, where
'currentChanged' gives you info about the former.

I did not run your code, but probably this patch should correct your
initial problem with the signal:

--- selectionModel.py   2008-11-19 22:36:44.789397158 +0100
+++ selectionModel.py.alberto   2008-11-19 22:52:03.341742383 +0100
@@ -112,13 +112,14 @@

                # signals/slots
                # ------------------------------------------------
-               self.connect(self.theSelectionModel, \
QtCore.SIGNAL("selectionChanged()"), self.getSelection) +               \
self.connect(self.theSelectionModel, +                            \
QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.getSelection)



        # methods
        # ------------------------------------------------
-       def getSelection(self):
+       def getSelection(self, selected, deselected):
                print "getSelection() ..."

                index = self.theSelectionModel.currentIndex()

hope it helps

Alberto

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic