我有一个QTableView
,它的垂直标题可见。默认情况下,此 header 已编号。不过,我不知道如何将文本(数字)居中。这是它现在的样子(红色部分是标题):
这是我目前拥有的代码。我尝试使用 CSS 应用对齐属性,但它不起作用。其他一切似乎都通过 CSS(着色)工作,但不是文本对齐。
ui->tableView->verticalHeader()->setStyleSheet(QStringLiteral("QHeaderView::section{background-color: #e5cbcb; text-align: center;}"));
如何让数字居中?
最佳答案
使用这些标志:
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.
关于c++ - 在 QTableView 中将垂直标题的文本居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37232302/