[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Animation with QPainter
From:       Matt Newell <newellm () blur ! com>
Date:       2006-11-30 17:31:32
Message-ID: 200611300931.33004.newellm () blur ! com
[Download RAW message or body]

On Thursday 30 November 2006 08:45, Matej Svejda wrote:
> Hi!
>
> I want to include an animation in my program (a metronome for KDE 3.5). I
> used QPainter for painting and QTimer for the animation.
> What bothers me is that the animation just isn't smooth. First I directly
> painted via e.g. QPainter::drawRect. Then I read somewhere that it is
> better to create a Pixmap and then use it. I did get a little better
> results with that but there still is this really anoying flickering.
> Maybe someone could tell me what I'm doing wrong or whether there is a
> better way to do this.
> The code for the animation can be downloaded here:
> http://www.aw-modell.at/mata/animationtest.tar.gz
>
> Thanks for any kind of help!
> Matej
>

Pass this to the widgets wflags
Qt::WNoAutoErase - indicates that the widget paints all its pixels. Updating, 
resizing, scrolling and focus changes should therefore not erase the widget. 
This allows smart-repainting to avoid flicker.

You'll have to make sure you repaint all pixels, but if you do that correctly 
there should be no flicker.  You'll either want to use a pixmap the same size 
of the widget, or make sure to paint each pixel only once( don't paint the 
background and then the square over it, instead paint the square, and use a 
qregion to paint the background everywhere except the square).

Matt
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic