Created
June 11, 2017 19:40
-
-
Save SAW4/b165d287aa01fbc1a41668fc8d1141cb to your computer and use it in GitHub Desktop.
Qt Fading animation : Py vs C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MainInterface::ShowPathToCurr() { | |
TreeNodeButton* NodeButton = qobject_cast<TreeNodeButton*>(sender()); | |
QPropertyAnimation *a; | |
int i = 1; | |
for (Node* curr = NodeButton->get_localref(); !curr->activated; curr=curr->prev,++i){ | |
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this); | |
a= new QPropertyAnimation(eff, "opacity"); | |
curr->Widgetptr->setGraphicsEffect(eff); | |
curr->Widgetptr->setGraphicsEffect(eff); | |
a->setDuration(1000+i*500); | |
a->setStartValue(1); | |
a->setKeyValueAt(0.5, 0); | |
a->setEndValue(1); | |
connect(a, SIGNAL(finished()), curr->Widgetptr, SLOT(fadeFinish())); | |
a->setEasingCurve(QEasingCurve::OutBack); | |
a->start(QAbstractAnimation::DeleteWhenStopped); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fade(self): | |
self.ui.hint.setText("File has been save successfully.") | |
self.ui.hint.setStyleSheet("color:lawngreen;") | |
self.effect= QGraphicsOpacityEffect(self.ui.hint) | |
self.animation = QtCore.QPropertyAnimation(self.effect, b"opacity") | |
self.ui.hint.setGraphicsEffect(self.effect) | |
self.animation.setStartValue(0) | |
self.animation.setKeyValueAt(0.5,1) | |
self.animation.setEndValue(0) | |
self.animation.setDuration(2000) | |
self.animation.start(QtCore.QAbstractAnimation.DeleteWhenStopped) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment