PyQt QTableWidget horizontalheaderlabel stylesheet

若如初见. 提交于 2019-12-11 22:31:13

问题


I used this to set the style for my QTableWidget. Everything in the table is affected except the horizontalheaderlabels and the row numbers.

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

So I tried this

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

But this doesn't seems to have any affect.

How do i set the style sheet for horizontalheaderlabel and the row numbers?


回答1:


You should check Qt Sylesheet Reference

You have to do something like

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

That is if you want different horizontal and vertical headers. Otherwise, this should do the job

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


来源:https://stackoverflow.com/questions/19198634/pyqt-qtablewidget-horizontalheaderlabel-stylesheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!