Nominate our 2022 Qt Champions!

QStyledItemDelegate and QStandardItem preventing change text , enable only select and copy

  • have a simple QStandardItem and QTableView and QStyledItemDelegate. They have delegates , I would like to disable the possibility for user to change the content of a column in the table, and allow only select and copy. I guess it related to QStyledItemDelegate::createEditor.

    When I set it to return 0, it just disable everything.

    @QWidget *InfoTableItemDelegate::createEditor(QWidget *parent,
    const QStyleOptionViewItem &option,
    const QModelIndex &index) const
    // return QStyledItemDelegate::createEditor(parent, option, index);
    return 0;

    my question is , how can i defined it so i can only select and copy , and disable the option to edit it like delete or change the text

  • Hi! I am not sure but maybe "QStandardItem::setFlags": will help

Log in to reply