Qt - How can I make a particular Column of my QTableView as Non Editable?

New Moon picture New Moon · Sep 27, 2012 · Viewed 10.3k times · Source

I have a QTableView with 4 Rows and 4 columns each representing their data's in it. By default the QTableView is editable. Now I want to make any particular column as non editable in my QTableView.

How can I do it?

Thanks in Advance.

Answer

SingerOfTheFall picture SingerOfTheFall · Sep 27, 2012

You can use the setItemDelegateForColumn() function. Implement a read-only delegate, and set it for the column you need.

You can also use the flags inside your model, and remove the Qt::ItemIsEditable flag for a specific column.