Results 1 to 1 of 1

Thread: Animation in Qt

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

    Default Animation in Qt

    Hey

    I have a problem with animation in Qt. The problem is that the position of animated objects is always the same, except the time when the window loses focus and regains it. When the window is resized those object have tendency to 'disappear'. I mean the frame is okay, but its content is not.

    Picture of frame before resize
    before.png

    ...and after
    after.png

    Qt Code:
    1. QGridLayout *gridLayout = new QGridLayout();
    2. QFrame *frame = new QFrame();
    3. frame->setLineWidth(3);
    4. frame->setMidLineWidth(3);
    5. frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
    6.  
    7. QVBoxLayout *layout = new QVBoxLayout(frame);
    8.  
    9. QLabel *label = new QLabel("label", frame);
    10. label->setEnabled(false);
    11.  
    12. QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(label);
    13. effect->setOpacity(1.0);
    14. label->setGraphicsEffect(effect);
    15.  
    16. layout->addWidget(label, 0, Qt::AlignHCenter);
    17. gridLayout->addWidget(frame, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignVCenter);
    18.  
    19. QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity");
    20. animation->setDuration(500);
    21. animation->setStartValue(0.0);
    22. animation->setEndValue(effect->opacity());
    23. animation->setEasingCurve(QEasingCurve::OutQuad);
    24. animation->start(QAbstractAnimation::DeleteWhenStopped);
    To copy to clipboard, switch view to plain text mode 
    Last edited by trasher; 19th May 2014 at 21:50.

Similar Threads

  1. Replies: 1
    Last Post: 27th July 2012, 16:33
  2. animation in qt
    By rimie23 in forum Qt Programming
    Replies: 4
    Last Post: 6th May 2012, 11:09
  3. QML Animation
    By ujwala in forum Qt Quick
    Replies: 3
    Last Post: 11th August 2011, 08:14
  4. Animation in Qt
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 3
    Last Post: 25th June 2009, 07:05
  5. Animation in Qt
    By yogesh884 in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2009, 09:56

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.