PDA

View Full Version : How to disable some columns from editing on a QTableWidget?



grantbj74
19th September 2011, 06:31
Hi,

I would like one column in my QTableWidget to be editable. With other columns read only.

I have done similar code on a different compiler by changing from single selection to row selection when the read only columns are selected.

Any ideas on how to achieve this?

Thanks
Brendan

pkj
20th September 2011, 15:07
Use QTableWidgetItem::column() to determine whether to edit or not. Better still, while new'in QTableWidgetItem, set its flags appropriately.
QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

grantbj74
21st September 2011, 06:32
Yes that does exactly what I want. Thanks