Hi,
I have a QTreeView having 10 rows and each row has 5 columns.
Now i want to make first 4 columns of each row readonly. Only the last column can be edited by the user.
How to do this. Pls help.
Hi,
I have a QTreeView having 10 rows and each row has 5 columns.
Now i want to make first 4 columns of each row readonly. Only the last column can be edited by the user.
How to do this. Pls help.
Reimplement flags() on the model, set the Qt::ItemIsEditable on items you want editable and clear the flag on others.
i have done this but now the row highlight color is gone.
i have MoveRowUp and MoveRowDone functions when am doing that row is not highlighted.
Only the last column which is editable is highlited
You are returning wrong flags. You should return default flags + optionally ItemIsEditable.
Thanks for ur reply wysota.
Actually am new to Qt so am not getting how to reimplement flags and make certain item editable and clearing flags.
Can u please elaborate through some sample code.
Thanks again.
This is plain C++. You inherit, reimplement the flags() method and use the bit logical operations to assemble a set of bits you want active and return the from the method. You can use the base class implementation to fetch the default flags.
Qt Code:
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; // enable ItemIsEditable for all items }To copy to clipboard, switch view to plain text mode
Bookmarks