使用这些标志:
Qt::AlignLeft 0x0001 Aligns with the left edge.
Qt::AlignRight 0x0002 Aligns with the right edge.
Qt::AlignHCenter 0x0004 Centers horizontally in the available space.
Qt::AlignJustify 0x0008 Justifies the text in the available space.
只使用样式表的另一种方法是:
setStyleSheet("QHeaderView { qproperty-defaultAlignment: AlignHCenter; }");
ui->tableView->verticalHeader()->setDefaultAlignment(Qt::AlignHCenter);
吗? - Lucas Araujo