QTableWidget和QHeaderView CSS

use*_*947 4 css qt qtablewidget qt5 qtstylesheets

我无法找到一种方法来主题化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);
}
Run Code Online (Sandbox Code Playgroud)

Mee*_*fte 6

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

警告:如果只设置一个background-colorQTableCornerButton,背景可能不会出现,除非你设置border属性为某个值.这是因为,默认情况下,QTableCornerButton绘制与背景颜色完全重叠的原生边框.

tableWidget.setStyleSheet("QTableWidget QTableCornerButton::section {"
    "background: red;"
    "border: 2px outset red;"
"}");
Run Code Online (Sandbox Code Playgroud)