2
The title of the question says it all: How can I prevent editing a particular column of a QTableWidget
?
I have already done some research and I think the solution is to use a few flags, but I couldn’t come up with a solution.
2
The title of the question says it all: How can I prevent editing a particular column of a QTableWidget
?
I have already done some research and I think the solution is to use a few flags, but I couldn’t come up with a solution.
1
It’s very simple, and as you say in the question the solution is to use flags. To deactivate the editing mode just do:
QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
This alternative has the advantage of not altering the behaviour of others flags only that of the flag Qt::ItemIsEditable
There are other alternatives, such as:
QTableWidgetItem *item = new QTableWidgetItem();
item->setFlags(item->flags() ^ Qt::ItemIsEditable);
The latter makes use of the XOR to play a switch role: each time it is executed it toggles the edit according to the current state.
Browser other questions tagged qt qtgui
You are not signed in. Login or sign up in order to post.
It was worth the force! once again! :)
– PhatsAndSmall