2 Attachment(s)
Avoid periodic flicker/drag during slideshow with QPropertyAnimation
I have come across a problem/bug in QPropertyAnimation, QPropertyAnimation produce periodic flicker/drag effect during animation of longer duration of about 1 second or two. For small duration animation (about 500 ms or less) the QPropertyAnimation produce smooth animation without that specific flicker/drag effect. That flicker/drag like effect appears round about every 500ms. And i need to come across some solution very quickly. I have attached the minimal compilable example reproducing the problem. Please have a look and help.
(The code was originally posted by wysota in response of the question by some other user on the forum for his own specific kind of problem)
I am using Qt5.5 in Windows10, Core i5 Laptop.
Code:
#include <QCoreApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QPropertyAnimation>
#include <QApplication>
Q_OBJECT
public:
l->addWidget(placeholder);
l->addWidget(b);
b->setText("click");
connect(b, SIGNAL(clicked()), this, SLOT(nextPage()));
current = 0;
}
public slots:
void nextPage() {
newPage->setAutoFillBackground(true);
newPage->setPalette(p);
newPage->setParent(placeholder);
QPropertyAnimation *anim = new QPropertyAnimation(newPage, "geometry", newPage);
QRect start
= placeholder
->rect
();
start.setTopLeft(start.topRight());
newPage->setGeometry(start);
anim->setStartValue(start);
anim->setEndValue(placeholder->rect());
anim->setDuration(4000);
anim->start();
if(current) {
QPropertyAnimation *anim = new QPropertyAnimation(current, "geometry", current);
anim->setStartValue(placeholder->rect());
QRect r
= placeholder
->rect
();
r.translate(-r.width(), 0);
anim->setEndValue(r);
anim->setDuration(4000);
connect(anim, SIGNAL(finished()), current, SLOT(deleteLater()));
anim->start();
}
current = newPage;
current->show();
}
private:
};
#include "main.moc"
int main(int argc, char **argv) {
Widget w;
w.show();
return app.exec();
}