以下是我目前尝试过的。标题文本可以正确改变颜色,但背景无法从默认值更改。
template<typename T>
inline QVariant TableModel<T>::headerData(int section, Qt::Orientation orientation, int role) const
{
//...
else if(role == Qt::BackgroundRole) {
return QBrush(m_display.headerBackground);
}
//...
}
我该如何设置背景颜色?