Important: Please read the Qt Code of Conduct -


  • someone please tell me that how to set a gif image on my centralwidget

  • Lifetime Qt Champion

    Just put a Qlabel there and set the GIF via setPixmap
    If you mean an animated gif, have a look at QMovie.

    alt text

    You can also set it to central with

        QPixmap pix(":/test.gif"); // note this is from an ressource file    
         QLabel *label = new QLabel;    

    alt text

  • Thanks alot sir

  • Ah!! sir one more thing i want set an animated gif on the background and i was able to do it with the help of qmovie on qlabel but when i want to add a pushbutton or anything else it doesn't appear on the screenAnnotation 2019-10-08 064225.png

    after running i got this
    Annotation 2019-10-08 064327.png
    you see there is no pushbutton on main form

    the code i have written is
    QMovie movie = new QMovie(":/Images/7T9364v.gif");

  • Think about what would be required to allow pushbuttons over top of an animated image. every time the background image frame is updated, all the higher z-order widgets would need to be checked and potentially repainted. From a programmatic perspective I would avoid adding widgets over top of an animation.

    You also need to consider that the animation and buttons are part of the same layout. If you really want buttons on an animation, shouldn't those buttons be children of the image, instead of peers in the parent layout?

Log in to reply