Implement paintSection for QHeaderView class

protected:
  virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const
  {
    QHeaderView::paintSection(painter, rect, logicalIndex);
    painter->drawRect(2, 2, 10, 10);
  }

      

The rectangle is not painting. But when paintSection is removed it paints. I need to draw a rectangle after calling paintSection.

+1


source to share


1 answer


As said in that , your question rect

is the area you should paint on.
If you paint outside of this area, your drawings can be erased by coloring other cells.

So use rect

to draw a rectangle:



painter->drawRect(rect.adjusted(2, 2, -2 , -2));

      

0


source







All Articles