Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

activate and deactivate a gif



  • hello
    I want when I press a button I activate the gif and when I press another button the gif will be stopped.
    The probleme is when I press to reactivate the gif for the second time the application crashes you find if attached my code:
    .h:
    QMovie *movie=new QMovie(":/images/foo.gif");

    //the first button
    if (!movie->isValid())
    {
    // Something went wrong :(
    }
    ui->label->setMovie(movie);
    movie->start();

    //second button
    movie->stop();


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you deleting your movie object at some point ?
    Did you try to run your application through a debugger ?


Log in to reply