I have a QTreeWidgetItem with two columns of data, is there any way to make only the second column editable? When I do the following:
QTreeWidge
Maybe a little late, but may help :
void MyClass::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) {
Qt::ItemFlags flags = item->flags();
if(column == 0)
{
item->setFlags(flags & (~Qt::ItemIsEditable));
}
else
{
item->setFlags(flags | Qt::ItemIsEditable);
}
}
Here 0 is the index of the column you want to make readonly.
flags & (~Qt::ItemIsEditable)
Sets the ItemIsEditable position to 0 regardless the previous flag of your item.
flags | Qt::ItemIsEditable
Sets it to 1 regardless the previous flag.