Hello,
How can I disable the editable rows in QTreeView, I'm using the standard model "QStandardItemModel"
Thanks.
Hello,
How can I disable the editable rows in QTreeView, I'm using the standard model "QStandardItemModel"
Thanks.
Use QStandardItem::setFlags() to remove Qt::ItemIsEditable which is turned on by default:
Qt Code:
item->setFlags(item->flags() & ~Qt::ItemIsEditable);To copy to clipboard, switch view to plain text mode
J-P Nurmi
I got this error: error C2039: 'setFlags' : is not a member of 'QAbstractItemModel'Qt Code:
To copy to clipboard, switch view to plain text mode
How I'm supoused to use QStandardItem with QAbstractItemModel?
So, you're not using QStandardItems to fill QStandardItemModel? Alternative approach is to reimplement QAbstractItemModel::flags() and make sure no Qt::ItemIsEditable is returned:
Qt Code:
Qt::ItemFlags MyStandardItemModel::flags(const QModelIndex& index) const { }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Thank you
My second question is: how to remove the dotted border in the selected row on the selected column like the picture below:
- If you want the focus rect to appear around the whole row instead, use QAbstractItemView::setSelectionBehavior() and QAbstractItemView::SelectRows.
- If you don't want the widget to receive focus at all, use QWidget::setFocusPolicy() and Qt::NoFocus.
J-P Nurmi
Bookmarks