Fade label's pixmap from current to another



  • What is the best way to achieve this?

    I can fade out the label, change the image when fading is complete, and then fade in with the new image.

    What I wish to achieve is fade the old image immediately to the new one.

    What is the best way to achieve this?


  • Moderators

    You can subclass QWidget/QFrame and do the painting yourself. On every time you set an pixmap to your widget start a QPropertyAnimation which updates a value and triggers an update() on your widget. In the paint method then use the value to first draw the old pixmap and then the new pixmap with an calculated opacity.

    Second solution would be to use 2 QLabels (one with the old pixmap and one with the new pixmap) and again use a QPropertyAnimation to animate a QOpacityGraphicsEffect's (set on the labels) "opacity" property.



  • Yes, I have already implemented it with the second solution that you mentioned on your post, but I hoped for something better.

    Thanks a lot :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.