Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Edit mode in the QTableView?

Tags:

c++

qt

I am using QTableView. It's working fine. But the problem is that if I double click the cell then it changes into edit mode. I need to disable the edit option. How to do that?

like image 225
saravanan Avatar asked Oct 05 '10 10:10

saravanan


3 Answers

Use the following:

QTableView table(...);
table.setEditTriggers(QAbstractItemView::NoEditTriggers);
like image 53
bruno Avatar answered Oct 20 '22 00:10

bruno


Try QAbstractItemView, which is the baseclass of QTableView where the EditTriggers enum (which NoEdittriggers is an element of) is declared. Taken from this link.

QTableView table(...);
table.setEditTriggers(QAbstractItemView::NoEditTriggers);
like image 24
korish Avatar answered Oct 20 '22 01:10

korish


Use the editTriggers property to change the behaviour. All possible values are described here.

QTableView view();
view.setEditTriggers(QAbstractItemView::NoEditTriggers);
like image 31
Patrice Bernassola Avatar answered Oct 20 '22 00:10

Patrice Bernassola