I have a tableview that has a checkbox in the first column of every row. The checkbox is returned from the data() method of the model view:
elif role == Qt.ItemDataRole.CheckStateRole and index.column() == 0:
val = self._data[index.row()][index.column()]
return Qt.CheckState.Checked if val else Qt.CheckState.Unchecked
The checkbox is aligned left in the cell and I would like it to be aligned center. I have searched online and have not found any clear examples. Online results talked about being able to do it by creating a custom delegate or a custom style proxy. Neither of them have worked for me.