Простой способ установить выравнивание столбца - через делегатов:
import sys
from PyQt5 import QtCore, QtWidgets
class AlignDelegate(QtWidgets.QStyledItemDelegate):
def initStyleOption(self, option, index):
super(AlignDelegate, self).initStyleOption(option, index)
option.displayAlignment = QtCore.Qt.AlignCenter
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.tableWidget = QtWidgets.QTableWidget(15, 6)
self.setCentralWidget(self.tableWidget)
for i in range(self.tableWidget.rowCount()):
for j in range(self.tableWidget.columnCount()):
it = QtWidgets.QTableWidgetItem("{}-{}".format(i, j))
self.tableWidget.setItem(i, j, it)
delegate = AlignDelegate(self.tableWidget)
self.tableWidget.setItemDelegateForColumn(2, delegate)
# for all columns:
# self.tableWidget.setItemDelegate(delegate)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.resize(640, 480)
w.show()
sys.exit(app.exec_())