如何更改QTableWidget的垂直标题的背景颜色?

时间:2020-11-05 18:02:05

标签: c++ qt qtablewidget qtstylesheets

我想更改QTableWidget的颜色。我几乎得到了想要的结果,但是垂直页眉中的两个区域仍然为白色:

enter image description here

在写这篇文章之前,我实际上设法也给左上角涂了颜色,但没有涂其他地方。这是我正在使用的样式表:

QTableCornerButton::section {
    background-color: #8b8d8e;
}

QHeaderView::section {
    color: white;
    background-color: #747678;
    gridline-color: #747678;
}

1 个答案:

答案 0 :(得分:0)

最后我自己找到了答案:

/*The top-left area is actually a button:*/
QTableCornerButton::section {
    background-color: #8b8d8e;
}
/*The lower part of the vertical header:*/
QHeaderView {
    background-color: #8b8d8e;
}

我发布的原始CSS(QHeaderView :: section)仅引用标头条目,而不引用标头本身。