Results 1 to 1 of 1

Thread: Avoid periodic flicker/drag during slideshow with QPropertyAnimation

  1. #1
    Join Date
    Sep 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.

    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QWidget>
    3. #include <QVBoxLayout>
    4. #include <QPushButton>
    5. #include <QLabel>
    6. #include <QPropertyAnimation>
    7. #include <QApplication>
    8.  
    9.  
    10. class Widget : public QWidget {
    11. Q_OBJECT
    12. public:
    13. Widget(QWidget *parent = 0) : QWidget(parent) {
    14. QVBoxLayout *l = new QVBoxLayout(this);
    15. placeholder = new QWidget;
    16. placeholder->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    17. l->addWidget(placeholder);
    18. l->addWidget(b);
    19. b->setText("click");
    20. connect(b, SIGNAL(clicked()), this, SLOT(nextPage()));
    21. current = 0;
    22. }
    23. public slots:
    24. void nextPage() {
    25. QWidget *newPage = new QLabel("page");
    26. newPage->setAutoFillBackground(true);
    27. QStringList c = QColor::colorNames();
    28. QPalette p = newPage->palette();
    29. p.setColor(QPalette::Window, QColor(c.at(qrand() % c.size())));
    30. newPage->setPalette(p);
    31. newPage->setParent(placeholder);
    32. QPropertyAnimation *anim = new QPropertyAnimation(newPage, "geometry", newPage);
    33. QRect start = placeholder->rect();
    34. start.setTopLeft(start.topRight());
    35. newPage->setGeometry(start);
    36. anim->setStartValue(start);
    37. anim->setEndValue(placeholder->rect());
    38. anim->setDuration(4000);
    39. anim->start();
    40.  
    41. if(current) {
    42. QPropertyAnimation *anim = new QPropertyAnimation(current, "geometry", current);
    43. anim->setStartValue(placeholder->rect());
    44. QRect r = placeholder->rect();
    45. r.translate(-r.width(), 0);
    46. anim->setEndValue(r);
    47. anim->setDuration(4000);
    48. connect(anim, SIGNAL(finished()), current, SLOT(deleteLater()));
    49. anim->start();
    50. }
    51.  
    52. current = newPage;
    53. current->show();
    54. }
    55. private:
    56. QWidget *placeholder;
    57. QWidget *current;
    58. };
    59.  
    60. #include "main.moc"
    61.  
    62. int main(int argc, char **argv) {
    63. QApplication app(argc, argv);
    64. Widget w;
    65. w.show();
    66. return app.exec();
    67. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files
    Last edited by shujaat; 12th January 2016 at 08:35. Reason: Inserting Code

Similar Threads

  1. how to make the qwtscale periodic?
    By ketan22584 in forum Qwt
    Replies: 1
    Last Post: 7th August 2012, 06:39
  2. Avoid flicker during slideshow with QPropertyAnimation
    By RazZziel in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2012, 17:18
  3. Replies: 2
    Last Post: 21st February 2012, 11:13
  4. How to apply the turnover effect to the image slideshow
    By Sirisha in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2011, 07:16
  5. Replies: 4
    Last Post: 16th April 2011, 10:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.