i have the following code defining the gui of my app
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 app
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 lock some of the cells. ( i already have code that expand the table ) how can i make some cells read only while keeping the others read write? i found this link How to make a column in QTableWidget read only? with a solution for the problem in C++, is python solution similar ?
EDIT: Removed the answer from the post and pasted as an answer