Read only column

  • I have a QTableView.
    I'd like to have the first column set as "read only" and all the others editable.
    How can I obtain this?

    I read the documentation and other websites and i've understand I should overide Qt::ItemIsEditable flag

    Could you provide me some examples?


  • Lifetime Qt Champion


    You need to reimplement the flags(const QModelIndex &index) function of your model.

    Something like:

    if (index.column() == 1) {
    return QAbstractModel::flags() & ~Qt::ItemIsEditable;

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.