How to make a column in QTableWidget read only?
Solution 1:
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.
Solution 2:
The result of using XOR depends on what the current state is. I'd suggest using
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
to make sure editing is turned off regardless of the current setting.
Solution 3:
I came to a better suggestion, just overwrite the cellDoubleClicked signal with a new SLOT. This is, if you want none of the cells to be modified