[Qt-interest] Xor'ing in paint event
Ender EREL
erelender at yahoo.com
Wed Aug 26 16:01:03 CEST 2009
Ian Thomson wrote:
> Hi
>
> This causes a stack overflow because calling the paintEvent is virtual,
> meaning that calling it on your 'this' pointer will call
> derived->paintEvent, even if you cast your this pointer to a Base type.
> So you're calling the function recursively forever, overflowing the stack.
>
> A better solution would be to add a function to the base class called
> 'draw' which takes a QPainter*. In the base class paintEvent, just make
> a QPainter in the standard way, and call the draw function. In the
> derived class, open a QPainter on an appropriately sized QImage, and
> then pass that along to the draw function.
>
> Cheers,
> Ian.
>
At first i thought of that too, but the base class is from a library
that another team at my company is developing therefore i am trying to
find a solution that does not require modifying the base class.
Best Regards.
--
Ender EREL
More information about the Qt-interest-old
mailing list