PyQt QTableWidget 水平标题标签样式表

Chr*_*ung 1 python pyqt stylesheet pyqt4

我用它来设置我的QTableWidget. 表中的所有内容都受到影响,除了horizontalheaderlabelsthe row numbers

Table.setStyleSheet("Background-color:rgb(100,100,100);border-radius:15px;")
Run Code Online (Sandbox Code Playgroud)

所以我试过这个

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

但这似乎没有任何影响。

如何设置的样式表horizontalheaderlabelthe row numbers

Yoa*_*ann 6

您应该检查Qt Sylesheet 参考

你必须做类似的事情

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

也就是说,如果您想要不同的水平和垂直标题。否则,这应该可以完成工作

stylesheet = "QHeaderView::section{Background-color:rgb(190,1,1);
                                   border-radius:14px;}"
Table.setStyleSheet(stylesheet)
Run Code Online (Sandbox Code Playgroud)