1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| #include "customheaderview.h"
|
| #pragma execution_character_set("utf-8")
|
| 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);
| }
|
| }
|
|