Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Animated gif in window play once

Animated gif in window play once

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ShodanS Offline
    ShodanS Offline
    Shodan
    wrote on last edited by
    #1

    Hello.

    I want to play an animated gif and make it stop at the last picture.

            QMovie *title = new QMovie("windowLogs/myTitle.gif");
            QLabel *titleLabel = new QLabel(&mainWindow);
            titleLabel->setMovie(title);
            titleLabel->move(13, 13);
            title->start();
    

    Using this code, the movie restarts again and again...

    Is there a simple way to make the loop stop?

    Thanks a lot.

    1 Reply Last reply
    0
    • apalomerA Offline
      apalomerA Offline
      apalomer
      wrote on last edited by
      #2

      You can try using the object's finish signal and connect it to the object's stop slot.

      1 Reply Last reply
      1
      • ShodanS Offline
        ShodanS Offline
        Shodan
        wrote on last edited by Shodan
        #3

        Thanks.

        I tried it like this:

                QMovie *title = new QMovie("windowLogs/myTitle.gif");
                QLabel *titleLabel = new QLabel(&mainWindow);
                titleLabel->setMovie(title);
                titleLabel->move(13, 13);
                title->start();
                connect(title, SIGNAL(finished()), title, QMovie::stop());
        

        But an error message comes:

        cannot call member function 'void QMovie::stop()' without object
        connect(title, SIGNAL(finished()), title, QMovie::stop()); ^

        I watched different examples but can't figure out what'sgoing wrong.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Shodan said in Animated gif in window play once:

          connect(title, SIGNAL(finished()), title, QMovie::stop());

          Should that not be

          connect(title, SIGNAL(finished()), title, SLOT(stop()));

          1 Reply Last reply
          3
          • ShodanS Offline
            ShodanS Offline
            Shodan
            wrote on last edited by
            #5

            Great!
            Thanks for the help.

            Programming is pretty new for me, and many examples way to complicate yet...

            Like this it works like a charm:

            QObject::connect(title, SIGNAL(finished()), title, SLOT(stop()));
            
            1 Reply Last reply
            1
            • ShodanS Offline
              ShodanS Offline
              Shodan
              wrote on last edited by
              #6

              Obviously it is also possible to disable or enable looping for animated gif files (and also set a repeat count) with free editors like "microsoft gif animator".

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved