[PyQt] table view row selection

despen at verizon.net despen at verizon.net
Sun Aug 22 01:38:23 BST 2010


I'm using PyQt4 with a tableview.
I have:

 tv.setSelectionBehavior(QAbstractItemView.SelectRows)
 tv.setSelectionMode(QAbstractItemView.SingleSelection)
 tv.setDragEnabled(True)
 tv.viewport().setAcceptDrops(True)
 tv.setAcceptDrops(True)
 tv.setDropIndicatorShown(True)
 tv.setDragDropMode(QAbstractItemView.InternalMove)

With this I mangaged to get drag/drop to work.
Now I'd like to select rows for update by clicking on them.

I found I could do this:

 QObject.connect(tv.selectionModel(),\
                     SIGNAL("selected(QItemSelection, QItemSelection)"),\
                     tm.MySelChg)

but that disables drag/drop.

Any hints on what I should set up so that a single click selects
a row for update?

Thanks.


More information about the PyQt mailing list