QHeaderView::paintSection
-
[code]
void HeaderView::paintSection(QPainter *painter, const QRect &, int) const
{
painter->drawText(0, 0, "abcde");
}
[/code]I need to draw text in derived from QHeaderView class. But this code does not work.
-
Hi,
What do you mean by "it does not work" ? What does not work ? What are you expecting to get ? What are you currently getting ?
-
[quote author="SGaist" date="1408998200"]Hi,
What do you mean by "it does not work" ? What does not work ? What are you expecting to get ? What are you currently getting ?[/quote]
The text does not drawing.
-
Are you sure it's called ? And why don't you draw in the given rectangle ?
-
Yes, I am sure. If I call drawRect(0, 0, 10, 10) the rectangle is drawing. But the text is not painting.
-
What happens if you call
@void HeaderView::paintSection(QPainter *painter, const QRect &rect, int) const
{
painter->drawText(rect, Qt::AlignCenter, "abcde");
}@?
-
Nothing happens. But I solved the problem using
[code]
painter->save();
QHeaderView::paintSection(painter, rect, logicalIndex);
painter->restore();
[/code]
I don't know what does it mean but it works. -
It calls the base implementation of painSection. So basically, you can remove the function from your class