Skip to main content
 首页 » 编程设计

python之PyQt4 Widgets 的样式表组件名称

2024年11月01日9bjzhanghao

我正在尝试学习为我的 python 程序创建外部 qss 文件(样式表),该程序是用 PyQt 编写的,外观更漂亮。

在Qt样式表的例子中,它使用了这个

 QTableView QTableCornerButton::section { 
 background: red; 
 border: 2px outset red; 

}

指定QTableWidget connerbutton(红色矩形)的样式属性。 但是,它没有说明应该如何处理其他组件名称。例如,我不知道如何更改 horizo​​ntalheaderlabel 和 verticalheader 样式。

当我使用样式表而不使用像这样的任何组件名称(如 QTableCornerButton)时

    QTableWidget { 
     selection-background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5, 
                                 stop: 0 #579599, stop: 1 #39B4BD); 
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, 
stop: 0 #D1DBEB, stop: 0.4 #C0D1EB,stop: 0.5 #ABBEDB, stop: 1.0 #95ABCC); 
border:1px solid #7286A3; 
border-top-left-radius: 9px; 
border-top-right-radius: 9px; 
border-bottom-left-radius: 9px; 
border-bottom-right-radius: 9px; 
padding:0px; 
 
 } 

它将样式应用于整个小部件而不是特定区域。

我在哪里可以在线找到样式表支持的小部件组件的名称(例如,QTableCornerButton)?

Qt Stylesheet example很好,但它没有提供我可以使用的所有名称和属性。

请您参考如下方法:

你看过文档了吗here ?