1
votes

I 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

1
1) Don't forget to write your question... 2) What is "disable everything"? 3) Returning 0 should be ok here, it doesn't create editor widget so you cannot edit the model.Synxis
thanks , all i want to be able to select and copy the text , but not edit it ( delete or change ) when i do this with return 0, i can't select and copy ituser63898

1 Answers

1
votes

If your data can be showed as simple text, then you can return a QLineEdit in read-only mode. If you have images or other types of data, maybe a selectable QLabel with some html in it (to make a QLabel selectable, you have to include Qt::TextSelectableByMouse or Qt::TextSelectableByKeyboard in the label's interaction flags).