2013-10-05 79 views
0

我用它來設置我的QTableWidget的樣式。除了horizontalheaderlabelsthe row numbers以外,表格中的所有內容都受到影響。PyQt QTableWidget horizo​​ntalheaderlabel樣式表

Table.setStyleSheet("Background-color:rgb(100,100,100);border-radius:15px;") 

所以,我想這個

Table.horizontalHeader().setStyleSheet("Background-color:rgb(190,1,1);border-radius:14px;" 

但這並不似乎有任何影響。

如何設置horizontalheaderlabelthe row numbers的樣式表?

回答

2

您應該檢查Qt Sylesheet Reference

你必須做一些像

stylesheet = "::section{Background-color:rgb(190,1,1);border-radius:14px;}" 
Table.horizontalHeader().setStyleSheet(stylesheet) 

,如果你想不同的水平和垂直接頭也就是說。否則,這應該做的工作

stylesheet = "QHeaderView::section{Background-color:rgb(190,1,1); 
            border-radius:14px;}" 
Table.setStyleSheet(stylesheet) 
+0

什麼'::節'的東西呢?通常我只會寫'(「Background-color:rgb(255,255,0);」)' –

+0

如果直接在水平標題上應用樣式表,它將應用於標題「background」,即不在文本單元上的標題。這就是::部分的用途。或者,您可以使用QHeaderview :: section {...}並將樣式表直接應用於表格窗口小部件 – Yoann