To add to that -- if you keep the brush as a member variable, then setting the brush on the painter with setBrush() does not increase memory use -- you have two "handles" to the brush but in fact only one instance of brush data. This works as long as you don't modify any of the "handles". If you do then a copy takes place so that each brush has its own instance of data. But since you modify the brush to apply the changes right away, you end up with a single instance of data again as the old data is deleted by QBrush. Same works for QPen, of course.
Bookmarks