设置QAbstractTableModel表头背景色的问题

chengshiding chengshiding 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role ==Qt::BackgroundRole)
{
//if(orientation == Qt::Vertical)
if (orientation == Qt::Horizontal)
switch (section)
{
case 0:
return QBrush(QColor(Qt::blue));
case 1:
return QVariant(QColor(Qt::blue));
default:
return QAbstractTableModel::headerData(section,orientation,role);
}


可以设置headerData的字体颜色,字体加粗。data的字体颜色,背景色,字体风格等。
但是就是不能设置headerData的背景色。
OS是xp
求解!
...全文
评论 8
收藏 已收藏
分享
返回顶部
chengshiding
Qt 21,503 成员 26,693 内容