pythonpyqtqgispythonqt

unable to select rows in table widget In PyQGIS


In PyQGIS design tablewidget, I have set table widget to be read-only and when I select particular,it is didn't read that row?

self.dlg.ui.tableWidget.item(row, 1).setFlags(Qt.NoItemFlags)

unable to select rows in table widget,to read datas.


Solution

  • You just have to use bitwise operations to deny the flag Qt.ItemIsEditable

    it = self.dlg.ui.tableWidget.item(row, 1)
    it.setFlags(it.flags() & ~Qt.ItemIsEditable)