QTreeView: change background color of specific column header
-
Is it possible to change the background color of a specific column of QTreeView header?
This can change the background color of all columns:
ui->tree->setStyleSheet("QHeaderView::section { background-color:red }");
This is not working:
ui->tree->model()->setHeaderData(col, Qt::Horizontal, QBrush(QColor("red")), Qt::BackgroundRole);
Is there any ideas?
Thank you!
-
Hi,
The style used to draw your application is free to ignore certain hints to follow the OS style they represent. That's why your second line may have no effect.
-
Please provide a minimal compilable example that reproduces this.