I am currently working with pyqt and have a table. In this table I want to center all the items both horizontally and vertically.
My code is:
for row_index in range(9):
for column_index in range(9):
item = self.ui.sudoku.item(row_index, column_index)
item.setTextAlignment(QtCore.Qt.AlignHCenter)
I tried adding the line to center it vertically: for row_index in range(9):
for row_index in range(9):
for column_index in range(9):
item = self.ui.sudoku.item(row_index, column_index)
item.setTextAlignment(QtCore.Qt.AlignHCenter)
item.setTextAlignment(QtCore.Qt.AlignVCenter)
But now the text only aligns centered only vertically. How can I make the text align centered in both dimensions?