I have the following code defining the gui of my application
class Ui (object): def setupUi(): self.tableName = QtGui.QTableWidget(self.layoutWidget_20) self.tableName.setObjectName(_fromUtf8("twHistoricoDisciplinas")) self.tableName.setColumnCount(4) self.tableName.setRowCount(3)
and the following code in my application
class MainWindow(QtGui.QMainWindow): def __init__(self): self.ui = Ui() self.ui.setupUi(self) self.createtable() #creating a tw cell def cell(self,var=""): item = QtGui.QTableWidgetItem() item.setText(var) return item def createtable(self): rows = self.tableName.rowCount() columns = self.tableName.columnCount() for i in range(rows): for j in range(columns): item = self.cell("text") self.ui.tableName.setItem(i, j, item)
I want to be able to add new rows and columns and edit them, but I want to block some of the cells. (I already have code expanding the table) how can I make some cells read-only while others are reading? I found this link. How to make a column in a QTableWidget read-only? with solving a problem in C ++, similar to python solution?
EDIT: Removed response from message and inserted as response
source share