The QPainter and QRectF provided to drawBackground and drawForeground are the same ones you would get by calling:
viewport()->rect();
QPainter(viewport());
viewport()->rect();
To copy to clipboard, switch view to plain text mode
right?
So, for example, if I had another function that was responsible for drawing a diagonal line across the widget, I could do something along the lines of
void drawDiagonalLine(){
a.drawLine(0,0,viewport()->rect().x(),viewport()->rect().y());
}
void drawDiagonalLine(){
QPainter a(viewport());
a.drawLine(0,0,viewport()->rect().x(),viewport()->rect().y());
}
To copy to clipboard, switch view to plain text mode
That way, one wouldn't be completely dependent on drawForeground and drawBackground. I could also have special case helper functions that are only occasionally called that don't need the QPainter and QRectF from drawForeground/drawBackground, as I could get them each time.
Bookmarks