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.
Normally you can press enter or F2? or double click to start editing a cell. this will disable that. It disables the users normal ways of start editing.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With