wumu
2024-05-10 b11ad2bb1946cf5356037f7a16e4e42558fd955e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "customheaderview.h"
 
CustomHeaderView::CustomHeaderView(Qt::Orientation orientation, QWidget *parent)
    :QHeaderView(orientation,parent)
{
 
}
 
void CustomHeaderView::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
{
    if (logicalIndex == 0) // 指定第一个表头项
    {
       painter->save();
       painter->fillRect(rect, Qt::red); // 设置背景色为红色
       //painter->setBackground(QBrush(Qt::red));
       painter->restore();
    }
    else
    {
       QHeaderView::paintSection(painter, rect, logicalIndex);
    }
 
}