How do I make a QTableView readonly?
-
Hi,
I need to prevent the user to- editing the columns in a QTableView, yet I don't find setReadOnly(). How is this accomplished?
Regards,
Juan -
-
@Christian-Ehrlicher No, that would make the model readonly - I only want the QTableView readonly...
-
@jdent The flags are for the view. Please read the docs.
-
@Christian-Ehrlicher sorry did not find any info on ItemFlags for QTableView
can you please be more specific? -
-
@jdent said in How do I make a QTableView readonly?:
@Christian-Ehrlicher sorry did not find any info on ItemFlags for QTableView
In Qt's model-view paradigm the flags are returned by the model: Qt::ItemFlags QAbstractItemModel::flags(const QModelIndex &index) const, values flags Qt::ItemFlags.
Qt::ItemIsEditable
determines whether the model tells the view items are editable or not. A view likeQTableView
will call this, behind the scenes without you doing anything, and make its interface correspond to what the model wants. @mpergand's implementation does not returnQt::ItemIsEditable
so items won't be editable.QTreeView
will show items as non-editable.
7/7