Mosi
Mosi

Reputation: 1258

Make Specific Columns of QTableView readonly with QStandardItemModel

I have a QTableView with its model which is QStandardItemModel. How can i make specific columns in tableView readOnly? It seems that i can't alter edit triggers of tableView since i want specific columns to be editable.

Upvotes: 1

Views: 2351

Answers (1)

vahancho
vahancho

Reputation: 21258

You can try to set QStandardItem::setFlags() for each item in that column, excluding Qt::ItemIsEditable flag. For example:

[..]
QStandardItem *item = new QStandardItem;
item->setFlags(Qt::NoItemFlags);
[..]

Upvotes: 3

Related Questions