Reputation: 55
I want to be able to change the column header but anything that I try it doesn't work. Below is example of what I want to change. I want to change the white of the header.
[Example]
Below is the style sheet that I have currently
self.treeView.setStyleSheet("background-color: rgb(0, 153, 255);\n"
#"color: rgb(0, 153, 255);\n"
"alternate-background-color: rgb(0, 153, 255);\n"
"border-style: solid;\n"
"border-color: rgb(0, 153, 255);\n"
"border-width: 2px;\n"
"border-radius: 10px;")
Let me know if you need more code!
Upvotes: 1
Views: 1590
Reputation: 958
Here is a small complete application that shows how to set a header style for a QTreeView:
import sys
from PyQt5 import QtWidgets
class Widget(QtWidgets.QTreeView):
def __init__(self):
super().__init__()
self.test_model = QtWidgets.QFileSystemModel(self)
self.setModel(self.test_model)
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet("QHeaderView::section { background-color: red }")
w = Widget()
w.show()
sys.exit(app.exec_())
For further information on styling the header see the docs.
Upvotes: 2