So I'm working on a map widget to place a drone on a map, and I don't understand all the existing code just yet. I'm wondering, as I can do
Qt Code:
viewport()->rect();To copy to clipboard, switch view to plain text mode
to get a painter to draw things to the widget and to get the widget's geometric properties, what is the point of the functions void drawBackground(QPainter * painter, const QRectF & rect) and void drawForeground(QPainter * painter, const QRectF & rect) when one could just create their own functions to deal with specific events instead of 2 functions for all cases? Also, are these 2 functions called when the QGraphicsView recieves a call to update()?
Is the benefit that when one calls drawForeground, it only replaces the items drawn in previous calls to drawForeground? In other words, If I were to draw a physical map of real world terrain in drawBackground, then call drawForeground each time the drone position changes, will it erase the drone drawn from the previous drawForeground before drawing another drone and without affecting the map? If I were to draw a picture from an image file with drawBackground that takes up the entire viewport, will it erase the stuff from the previous call to drawForeground?
Bookmarks