QTableView - not allow user to edit cell


I created a QTableView with a QSqlTableModel. By standard, double-clicking on the cells will mark them and the user can edit them. I want, that the user isn't allowed to do that. He is allowed to mark the whole row by clicking on a single cell, but not to edit the cell. How can I do that?

8/30/2009 1:03:20 AM

Accepted Answer

Depending on whether you are coding everything or doing things in the designer, set

  • editTriggers to QAbstractItemView::NoEditTriggers
  • selectionBehavior to QAbstractItemView::SelectRows
  • optionally set selectionMode to QAbstractItemView::SingleSelection if you want the user to select exactly one row

on the tableview object the appropriate calls will all be prefixed with set e.g setEditTriggers() in the Designer you can find these option in the AbstractItemView section

8/25/2009 5:11:51 PM

Try this:


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow