Important: Please read the Qt Code of Conduct -

How to make te selected columns of QTableWidget as ReadOnly

  • Hi All

    I have one table created using QTableWidget.
    For this table I want odd column cells to be editable
    & even column cells to be readOnly.

    How to do this?

  • You can set the items in the even columns to read only like this:

    QTableWidgetItem *twItem = tableWidget->item(3, 4);
    twItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
    // if you do not need selectable items this is ok:

    Or set the flags during creation of the items, of course.

Log in to reply