I have a QTableView
with the vertical header visible. By default, this header is numbered. I cannot figure out how to center the text (numbers), though. Here's what it looks like now (the red parts are the headers):
Here is the code I currently have. I tried applying an alignment property with CSS, but it doesn't work. Everything else seems to work via CSS (coloring), but not the text alignment.
ui->tableView->verticalHeader()->setStyleSheet(QStringLiteral("QHeaderView::section{background-color: #e5cbcb; text-align: center;}"));
How can I center the numbers?
With these flags:
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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments