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
frame->setLineWidth(3);
frame->setMidLineWidth(3);
label->setEnabled(false);
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(label);
effect->setOpacity(1.0);
label->setGraphicsEffect(effect);
layout->addWidget(label, 0, Qt::AlignHCenter);
gridLayout->addWidget(frame, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignVCenter);
QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity");
animation->setDuration(500);
animation->setStartValue(0.0);
animation->setEndValue(effect->opacity());
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->start(QAbstractAnimation::DeleteWhenStopped);
QGridLayout *gridLayout = new QGridLayout();
QFrame *frame = new QFrame();
frame->setLineWidth(3);
frame->setMidLineWidth(3);
frame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
QVBoxLayout *layout = new QVBoxLayout(frame);
QLabel *label = new QLabel("label", frame);
label->setEnabled(false);
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(label);
effect->setOpacity(1.0);
label->setGraphicsEffect(effect);
layout->addWidget(label, 0, Qt::AlignHCenter);
gridLayout->addWidget(frame, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignVCenter);
QPropertyAnimation *animation = new QPropertyAnimation(effect, "opacity");
animation->setDuration(500);
animation->setStartValue(0.0);
animation->setEndValue(effect->opacity());
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->start(QAbstractAnimation::DeleteWhenStopped);
To copy to clipboard, switch view to plain text mode
Bookmarks