Set QAbstractItemView::NoEditTriggers with QTableView::setEditTriggers.
For the second problem, you either make the selection model available in the delegate(an easy solution), or for every item you add some custom boolean data(for a user role) which tells you if the item is selected or not.
For the first solution, you can pass the view as the delegate's parent when you construct it. You can cast parent() inside the delegate back to the view and access its selection model.
For the second solution, you can get the data for your role in the delegate's paint and see if it is selected.
EDIT: I think you can use QStyleOptionViewItem::state variable. If it QStyle::State_selected, then the item is selected. I am not sure if it contains valid values when it is passed to you.
EDIT2: I just had a look at the QItemDelegate::paint implementation. It seems that QStyleOptionView::state is valid, so you can just test for QStyle::State_Selected.




Reply With Quote
Bookmarks