Mar-31-2017, 01:59 PM
Hello,
I use a table with tableview. In one of the Columns I present boolean values as checkbox. For this purpose I implimentet a checkbox as single GUI element. I will implement a progress that the checkbox in the table column changed his state if the gui checkbox changed his state. But the problem is. If I select the row, I select a column to and if I do not select the column with the checkbox and I click the checkbox in the gui the wrong cell changed his value. So I create the follwing idea:
I create a new Function in the tablemodel and I set the column with the value for the correct one. But if I do that and I clicked the gui checkbox no values changed in the table.
I hope your able to understand my english ;)
greets niesel
I use a table with tableview. In one of the Columns I present boolean values as checkbox. For this purpose I implimentet a checkbox as single GUI element. I will implement a progress that the checkbox in the table column changed his state if the gui checkbox changed his state. But the problem is. If I select the row, I select a column to and if I do not select the column with the checkbox and I click the checkbox in the gui the wrong cell changed his value. So I create the follwing idea:
I create a new Function in the tablemodel and I set the column with the value for the correct one. But if I do that and I clicked the gui checkbox no values changed in the table.
1 2 3 4 5 6 7 8 9 |
def set_checkbox_clicked( self ): index = self .dataTBL.selectedIndexes()[ 0 ] value = None model = self .dataTBL.model() if self .reBezChbx.isChecked(): value = True else : value = False model.setDataCheckdata(index, value, QtCore.Qt.EditRole) |
1 2 3 4 5 6 7 8 |
def setDataCheckdata( self , index, value, role = QtCore.Qt.EditRole): if role = = QtCore.Qt.EditRole: row = index.row() #Selected row column = 2 #Only the thirt Column should set this value data = value self ._data[row][column] = data self .dataChanged.emit(index, index) return True |
greets niesel