I have class Paintable
that is able to paint itself with QPainter
provided as an argument:
class Paintable
{
public:
virtual void paint(QPainter*) = 0;
};
Instances of this class are being painted on a single QImage:
QImage paint(const std::vector<Paintable*>& paintables) {
QImage result;
QPainter p(&result);
for(int i = 0; i < paintables.size(); ++i) {
paintables[i]->paint(&p);
}
return result;
}
What I want to achieve is that function paint
could also form a matrix of size equal to result
image size in which each cell contains a pointer to Paintable
which has drawn corresponding pixel in result
image (something like z-buffer).
It could be achieved easily if draw methods of QPainter
somehow let me know of which pixels of QPaintDevice
were changed during last draw operation. Any ideas of how to do it? Should I create class derived from QPaintDevice
or QPaintEngine
?
I am using Qt 4.6.4.
Thanks.