On 30 November 2006 19:31, Matt Newell wrote: > 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. Hm... with a Qtimer triggered draw function that draws the new pixmap and bitBlt() it to the QWidget, there shouldn't be any flickering anyway. Alright, had a look at the demo code. Don't call update() in move(). Instead, draw your pixmap in move() and bitBlt() it. On the other hand, there seems to be a better way to do it. You are wasting a lot of CPU cycles for redrawing the pixmap over and over. If your metronome isn't too big so that memory isn't an issue, you could pre-draw a couple of pixmaps and simply bitBlt() the next one in move(). Uwe -- Mark Twain: I rather decline two drinks than a German adjective. http://www.SysEx.com.na >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<