This line:
absolutely does work; that is a fundamental feature of C++ and nothing to do with Qt. Actually, all of the lines you marked work, they just do not do what you expect.Qt Code:
//p.setBrush(*_backGround); <--- DOESN'T WORKTo copy to clipboard, switch view to plain text mode
You need to understand that QPainter::setBrush() takes a copy of the brush, and setPen() a copy of the QPen, you pass it. You can change the QBrush pointed to by your pointer after a call to QPainter::setBrush() but this will have no effect on the painter because the QBrush referenced through your pointer is not the same QBrush instance as the one used by QPainter. The same goes for QPen. QBrush and QPen are value objects and are designed to be be efficiently copied, there's really nothing to be gained from heap allocating them.
Bookmarks