Qt-interest Archive, March 2002
Re: paintEvent query
Message 1 in thread
On Thursday 28 February 2002 02:54 pm, you wrote:
> Hi,
>
> Why does this work on every call to paintEvent
>
> QPainter painter( this );
>
> painter.setPen( QPen( white, 3 ) );
>
> // fer1-video
> painter.drawLine( 250, 76, 400, 76 );
> painter.drawLine( 400, 76, 400, 150 );
>
> But this only works the first time
>
> QPainter* painter = new QPainter( this );
>
> painter->setPen( QPen( white, 3 ) );
>
> // fer1-video
> painter->drawLine( 250, 76, 400, 76 );
> painter->drawLine( 400, 76, 400, 150 );
Because QPainter object for your widget has been created and will
not be deleted at the end of scope (it exists all the time). Put
"delete painter;" at the end of scope.
Mariusz Lotko
--
[ signature omitted ]