[PyKDE] how to give focus to a particular cell in QTableView

Olivier Fournier o.fournier at perigord.com
Sun Jul 30 10:19:01 BST 2006


Thank you for your help.

Finally I write this:

  tv = QTableView()
  sm = QStandardItemModel(5, 5)
  tv.setModel(sm)
  id = sm.index(2, 2, QModelIndex())
  tv.setCurrentIndex(id)
  tv.edit(id)

Olivier


David Boddie wrote:
> 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
>
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>
>   




More information about the PyQt mailing list