I am using QTreeWidget, such a nice convenience class for us porters from Qt 3 -> 4, but I am unable to find a way to make a particular column of a QTreeWidgetItem editable while the other columns are not. Currently, I make an item editable upon creation like this:
item->setFlags(item->flags() | Qt::ItemIsEditable);
item->setFlags(item->flags() | Qt::ItemIsEditable);
To copy to clipboard, switch view to plain text mode
But this makes all the columns editable, whereas I just want to be able to edit, say, column 2. I tried not setting the item flags as above, and instead calling
tree_widget->editItem(item,2);
tree_widget->editItem(item,2);
To copy to clipboard, switch view to plain text mode
in my slot for itemDoubleClicked(), after checking that the double-clicked column is 2. But that fails because the item must have its editable flag set to true for editItem() to succeed.
What I'd like to see is a column-specific QTreeWidgetItem::setFlags() function, i.e. QTreeWidgetItem::setFlags(Qt::ItemFlags flags, int col = -1). How to get the desired effect without resorting to subclassing? Ask TrollTech for an enhancement?
I'm at Qt 4.2.1.
Advice, anyone?
thanks,
McKee
Bookmarks