【问题标题】:Changing the colors of QTableView改变 QTableView 的颜色
【发布时间】:2015-12-14 11:16:01
【问题描述】:

我想在这两个地方更改 PyQt5 中 Table Widget 的颜色,但找不到方法:

到目前为止,这是我的样式表:

QTableView QHeaderView::section
    {
    background-color:rgb(48, 48, 72);
    color:white;
    }

QTableView QHeaderView::section:checked
    {
    background-color: rgb(48, 48, 72);
    color:white;
    }

QTableView QTableCornerButton::section {
    Background-color:rgb(48, 48, 72);
}

QTableView,QListView::section {
    Background-color:rgb(48, 48, 72);
}

【问题讨论】:

    标签: python qt pyqt5 qtablewidget


    【解决方案1】:
    QTableView QHeaderView {}
    

    设置没有节的 HeaderView 的属性

    QTableView QHeaderView::section {}
    

    HeaderViews 部分之一,即使是选中的部分,如果没有为它们设置不同的属性。因此,您只需将代码的第一行替换为

    QTableView QHeaderView, QTableView QHeaderView::section
    

    部分

    QTableView QHeaderView::section:checked {}
    
    只需要

    ,如果检查部分应具有不同的属性

    这样您就可以轻松地编写代码

    QTableView, QTableView QHeaderView,  
    QTableView QHeaderView::section, QTableView QTableCornerButton:section
        {
        background-color:rgb(48, 48, 72);
        color:white;
        }
    

    并且仅在需要时

    QTableView QVerticalHeaderView::section:checked
        {
        background-color:rgb(255, 0, 0);
        color:white;
        }
    

    【讨论】:

      猜你喜欢
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多