Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to disable editing in QTableView



  • Hi All

    I have created a QTableView & I m using the different table view with same model in 2 different tabs.
    Here I want set different FLAG property[i.e enable & disable] to my table view located in 2 different tabs.
    How to achieve this?



  • Does this solve the problem?

    @tableView.setEditTriggers(QAbstractView::NoEditTriggers);@



  • That works. If you want to have more detailed control, you will need to use a proxy model and modify the editable flags in there.



  • If you don't use the "setData" on the model, that will be read-only. And don't add the "Qt::ItemIsEditable" to the flags.



  • [quote author="fluca1978" date="1320833028"]Does this solve the problem?

    @tableView.setEditTriggers(QAbstractView::NoEditTriggers);@
    [/quote]

    I think is

    @tableView.setEditTriggers(QAbstractItemView::NoEditTriggers);@


Log in to reply