How to draw text derived from QHeaderView class

I need to draw text in a QHeaderView derived class. But this code doesn't work.

void HeaderView::paintSection(QPainter *painter, const QRect &, int) const
{
    painter->drawText(0, 0, "abcde");
}

      

+1


source to share


1 answer


The documentation says:

Underlines the section indicated by the given boolean identifier using the given artist and direct.



This means that you must use the rect parameter as a parameter:

void HeaderView::paintSection(QPainter *painter, const QRect& rect, int) const
{
    painter->drawText(rect, Qt::AlignCenter, "abcde");
}

      

+5


source







All Articles