【问题标题】:QTableWidget and QHeaderView CSSQTableWidget 和 QHeaderView CSS
【发布时间】:2014-11-28 06:09:40
【问题描述】:

我找不到为 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);
}

【问题讨论】:

    标签: css qt qt5 qtablewidget qtstylesheets


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2019-01-12
      相关资源
      最近更新 更多