I tried the CSS code:
QTableView QHeaderView::section {
text-align: center;
}
And it did not help me.
PS I write the SCADA system in the WinCC OA that uses Qt, and there you can change the appearance of components only using CSS
I tried the CSS code:
QTableView QHeaderView::section {
text-align: center;
}
And it did not help me.
PS I write the SCADA system in the WinCC OA that uses Qt, and there you can change the appearance of components only using CSS
As seen in the source code for
QHeaderView::paintSectionQHeaderViewdoes not uses the stylesheet to define the text alignment, only values from thedefaultAlignmentor the data from the header's model (Qt::TextAlignmentRole).Now, if your default alignment is either
Qt::AlignLeftorQt::AlignRight, you can use the section padding to automatically center it:The opposite is not true: if default alignment is center, other calculus affect how padding is used and cannot be used to automatically left- or right-align text.