Results 1 to 6 of 6

Thread: Qt flickering animation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Qt flickering animation

    Hi Everyone,
    I have a problem creating a simple animation with Qt animation.
    I have a small image located at the bottom right corner of the screen, i am trying to create animation that will enlarge the picture by streching it from the the top left corner of the image and streching it to the center of the screen.
    I managed to do that, but, it's very notiable that qanimation makes it flicker (the right border of the picture, and it doesn't turns out good)
    I also did that with no animation, but with a timer, and changing window geometry , but i had the same problem, seems that it's not refreshing fast enough, creating flickering in the right border of the picture.

    here are the 2 examples:
    1 - using property animation (geometery)
    Qt Code:
    1. animation = new QPropertyAnimation(this, "geometry");
    2. animation->setDuration(555);
    3. animation->setEasingCurve(QEasingCurve::Linear);
    4. animation->setStartValue(QRect(availableScreenSize.width()-minWidth-WINDOW_PADDING,availableScreenSize.height()-minHeight-WINDOW_PADDING,minWidth,minHeight));
    5. animation->setEndValue(QRect(availableScreenSize.width()-maxWidth-WINDOW_PADDING,availableScreenSize.height()-maxHeight-WINDOW_PADDING,maxWidth,maxHeight));
    To copy to clipboard, switch view to plain text mode 
    2 - using a timer
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include <QDesktopWidget>
    4. #include <QDebug>
    5.  
    6. Widget::Widget(QWidget *parent) :
    7. QWidget(parent),
    8. ui(new Ui::Widget)
    9. {
    10. ui->setupUi(this);
    11. this->setStyleSheet("background:transparent;");
    12. this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
    13.  
    14. availableScreenSize = qApp->desktop()->availableGeometry();
    15.  
    16. //Growing from right to left
    17. this->setGeometry(availableScreenSize.width()-165,availableScreenSize.height()-95,160,90);
    18. //Growing from left to right
    19. //this->setGeometry(200,200,160,90);
    20.  
    21. timeLine = new QTimeLine();
    22. timeLine->setDuration(2222);
    23. timeLine->setFrameRange(1, 800);
    24. connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(update()));
    25.  
    26. counter = 0;
    27.  
    28. timeLine->start();
    29. }
    30.  
    31. Widget::~Widget()
    32. {
    33. delete ui;
    34. }
    35.  
    36. void Widget::paintEvent(QPaintEvent * /* event */)
    37. {
    38. counter++;
    39. qDebug() << counter;
    40.  
    41. qApp->processEvents();
    42. //Growing from right to left
    43. this->setGeometry(availableScreenSize.width()-165-this->width()-1,availableScreenSize.height()-95-this->height()-1,this->width()+1,this->height()+1);
    44.  
    45. //Growing from left to right
    46. //this->setGeometry(200,200,this->width()+1,this->height()+1);
    47.  
    48. if(timeLine->currentFrame() == 800)
    49. {
    50. qApp->exit(1);
    51. }
    52. }
    To copy to clipboard, switch view to plain text mode 

    Now the weired thing here is that if the animation is from left 2 right - it looks smooth... once the direction is changed from right 2 left the entire right border is "jumpy" .

    I'll appriciate any help that you can give me.
    Thanks!
    Last edited by high_flyer; 3rd May 2011 at 14:08. Reason: code tags

Similar Threads

  1. flickering in frame moving animation
    By Seth90 in forum Qt Programming
    Replies: 0
    Last Post: 23rd April 2011, 12:55
  2. Flickering problem
    By yagabey in forum Qt Programming
    Replies: 2
    Last Post: 5th May 2010, 12:25
  3. Flickering
    By Pembar in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2009, 19:21
  4. QtOgreFramework flickering with qt 4.5
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2009, 10:52
  5. flickering x-scale
    By sun in forum Qwt
    Replies: 2
    Last Post: 1st October 2008, 07:57

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
  •  
Qt is a trademark of The Qt Company.