import sys

from PyQt6.QtCore import QAbstractTableModel, QLibraryInfo, qVersion, Qt
from PyQt6.QtWidgets import QApplication, QTableView, QWidget



class M(QAbstractTableModel):
    alignment = Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignHCenter

    def rowCount(self, *a):
        return 4
    def columnCount(self, *a):
        return 1
    def data(self, index, role):
        row = index.row()
        if row == 0:
            if role == Qt.ItemDataRole.DisplayRole:
                return "alignment"
            if role == Qt.ItemDataRole.TextAlignmentRole:
                return self.alignment
        if row == 1:
            if role == Qt.ItemDataRole.DisplayRole:
                return "int(alignment)"
            if role == Qt.ItemDataRole.TextAlignmentRole:
                return int(self.alignment)
        if row == 2:
            if role == Qt.ItemDataRole.DisplayRole:
                return "Qt.AlignmentFlag(alignment)"
            if role == Qt.ItemDataRole.TextAlignmentRole:
                return Qt.AlignmentFlag(self.alignment)
        if row == 3:
            if role == Qt.ItemDataRole.DisplayRole:
                s = f"PyQt {qVersion()}  "
                return s * 4
        return None


if __name__ == '__main__':
    print('Python {}.{}'.format(sys.version_info[0], sys.version_info[1]))
    print(qVersion())
    app = QApplication([])
    v = QTableView()    
    v.setWindowTitle("PyQt " + qVersion())
    v.setModel(M())
    v.resizeColumnsToContents()
    v.resize(v.sizeHint())

    v.show()
    app.exec()
