问题
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