Qt animation problem - flickering geometry animation -


i have problem creating simple animation qt animation. have small image located @ bottom right corner of screen, trying create animation enlarge picture streching the top left corner of image , streching center of screen. managed that, but, it's notiable qanimation makes flicker (the right border of picture, , doesn't turns out good) did no animation, timer, , changing window geometry , had same problem, seems it's not refreshing fast enough, creating flickering in right border of picture.

here 2 examples:

1 - using property animation (geometery)

animation = new qpropertyanimation(this, "geometry"); animation->setduration(555); animation->seteasingcurve(qeasingcurve::linear); animation->setstartvalue(qrect(availablescreensize.width()  -minwidth     -window_padding,availablescreensize.height() - minheight     -window_padding,minwidth,minheight)); animation->setendvalue(qrect(availablescreensize.width() - maxwidth     -window_padding,availablescreensize.height() - maxheight     -window_padding,maxwidth,maxheight)); 

2 - using timer

#include "widget.h" #include "ui_widget.h" #include <qdesktopwidget> #include <qdebug>  widget::widget(qwidget *parent) : qwidget(parent), ui(new ui::widget) {     ui->setupui(this);     this->setstylesheet("background:transparent;");     this->setwindowflags(qt::framelesswindowhint | qt::windowstaysontophint         | qt::tool);      availablescreensize = qapp->desktop()->availablegeometry();      //growing right left     this->setgeometry(availablescreensize.width() - 165,         availablescreensize.height()-95,160,90);     //growing left right     //this->setgeometry(200,200,160,90);      timeline = new qtimeline();     timeline->setduration(2222);     timeline->setframerange(1, 800);     connect(timeline, signal(framechanged(int)), this, slot(update()));      counter = 0;      timeline->start(); }  widget::~widget() {     delete ui; }  void widget: aintevent(qpaintevent * /* event */) {     counter++;     qdebug() << counter;      qapp->processevents();     //growing right left     this->setgeometry(availablescreensize.width()  -165          - this->width()-1,availablescreensize.height() - 95         - this->height()-1,this->width()+1,this->height()+1);      //growing left right     //this->setgeometry(200,200,this->width()+1,this->height()+1);      if(timeline->currentframe() == 800)     {         qapp->exit(1);     } } 

now weired thing here if animation left 2 right - looks smooth... once direction changed right 2 left entire right border "jumpy" .

i'll appriciate can give me. thanks!

i'm experiencing same problem animating scaling of qgraphicspixmapitem. unlike case, i'm using setscale(scalevalue) instead of setgeometry because method not available qgraphicspixmapitem. able remove flicker using following code (note: i'm using pyside binding qt should able find corresponding c++ methods easily):

in initializer qgraphicspixmapitem class, called:

self.settransformationmode(qt.smoothtransformation) self.setcachemode(pyside.qtgui.qgraphicsitem.devicecoordinatecache) 

in qgraphicsview:

self.setcachemode(qgraphicsview.cachebackground) self.setrenderhints(pyside.qtgui.qpainter.antialiasing | pyside.qtgui.qpainter.smoothpixmaptransform) 

even though flicker gone, animation still bit jerky.

if has better solution, appreciate if post it. thanks.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -