QTableWidget和QHeaderView的CSS

4

我找不到主题化QHeaderView左上角的方法。也许它是在QTableWidget中的一部分,但是我无法确定...

示例:http://i.imgur.com/VmHHdan.png
History {
    background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 black, stop:1 gray);
}

* {
    font: 500 12pt "Cantarell";
    color: rgba(255, 255, 255, 200);
}

QTableWidget {
    background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 black, stop:1 blue);
}

QTableWidget::item {
    hborder: 5px solid rgba(68, 119, 170, 150);
    background-color:rgba(68, 119, 170, 125);
}

QHeaderView, QHeaderView::section {
    background-color: rgba(128, 128, 128, 128);
}
1个回答

8

QTableWidget中的角部小部件实现为QAbstractButton,可以使用QTableWidget QTableCornerButton::section选择器进行样式设置。

警告:如果您只在QTableCornerButton上设置了background-color,则在不设置border属性的情况下,背景可能不会显示。这是因为默认情况下,QTableCornerButton绘制一个完全重叠背景颜色的本地边框。

tableWidget.setStyleSheet("QTableWidget QTableCornerButton::section {"
    "background: red;"
    "border: 2px outset red;"
"}");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接