and*_*dre 8 c++ qt qtableview qabstracttablemodel
以下是我目前正在尝试的内容.标题文本正确更改颜色,但背景不会更改默认值.
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);
}
//...
}
Run Code Online (Sandbox Code Playgroud)
如何设置背景颜色?
Jim*_*mmy 18
您可以在QTableView上设置样式表
ui->tableView->setStyleSheet("QHeaderView::section { background-color:red }");
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅http://doc.qt.io/qt-4.8/stylesheet-examples.html