[PyKDE] how to give focus to a particular cell in QTableView
David Boddie
david at boddie.org.uk
Sat Jul 29 18:05:13 BST 2006
On Sat Jul 29 16:23:12 MEST 2006, Olivier Fournier wrote:
> I don't understand how to give the focus to an item in a TableView.
> With mouse I can make what I want but I need to edit a particular cell.
You could try calling QAbstractItemView.edit() with the model index
corresponding to the cell you want to edit. For example:
tv = QTableView()
sm = QStandardItemModel(5, 5)
tv.setModel(sm)
tv.edit(sm.index(2, 2, QModelIndex()))
That may not give keyboard focus to the cell itself, so you may also need
to take a look at QWidget.setFocus(), calling the tree view's setFocus()
method to make sure that the user can just start typing as soon as the
cell becomes editable.
David
More information about the PyQt
mailing list