How to make a column in QTableWidget read only?

Narek picture Narek · Apr 4, 2010 · Viewed 71.5k times · Source

I would like to have one column in QTableWidget NOT editable.
In forums I have read a lot about some flags but could not manage to implement.

Answer

Narek picture Narek · Apr 4, 2010

Insert into the QTableWidget following kind of items:

QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

Works fine!

EDIT:

QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(item->flags() ^ Qt::ItemIsEditable);

This is a better solution. Thanks to @priomsrb.