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. How to apply gif to Qpushbutton
Forum Updated to NodeBB v4.3 + New Features

How to apply gif to Qpushbutton

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 6.8k 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.
  • B Offline
    B Offline
    Beginner1
    wrote on last edited by
    #1

    Hi,
    Is there any way of applying a gif animation to a pushbutton?
    The setMovie Function only works with the labels. Is it possible to add a gif animation to pushbutton as an icon?

    D 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi and welcome to devnet,

      Out of curiosity, why do you need such a button for ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      1
      • B Beginner1

        Hi,
        Is there any way of applying a gif animation to a pushbutton?
        The setMovie Function only works with the labels. Is it possible to add a gif animation to pushbutton as an icon?

        D Offline
        D Offline
        Devopia53
        wrote on last edited by
        #3

        @Beginner1

        like this:

        auto movie = new QMovie(this);
        movie->setFileName(":/sample.gif");
        connect(movie, &QMovie::frameChanged, [=]{
            pushButton->setIcon(movie->currentPixmap());
        });
        movie->start();
        

        If the feature is used frequently, subclass the button to redefine it.

        1 Reply Last reply
        4
        • SGaistS SGaist

          Hi and welcome to devnet,

          Out of curiosity, why do you need such a button for ?

          B Offline
          B Offline
          Beginner1
          wrote on last edited by Beginner1
          #4

          @SGaist
          Thank U :D
          I have a complex animation of button that rotates and transforms into a tick so i wanted to apply that animation on the button when i click it I will learn to make these animations with QML later as i m a beginner currently so applied a gif :)

          @Devopia53

          Thank U for your help :D
          Also,
          Can i make that button clickable only once after i the movie starts ?

          jsulmJ 1 Reply Last reply
          0
          • B Beginner1

            @SGaist
            Thank U :D
            I have a complex animation of button that rotates and transforms into a tick so i wanted to apply that animation on the button when i click it I will learn to make these animations with QML later as i m a beginner currently so applied a gif :)

            @Devopia53

            Thank U for your help :D
            Also,
            Can i make that button clickable only once after i the movie starts ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Beginner1 said in How to apply gif to Qpushbutton:

            Can i make that button clickable only once after i the movie starts ?

            You can disable it after first click

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You can use the QMovie::started signal and a lambda to call setEnabled(true) on your button.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3
              • B Offline
                B Offline
                Beginner1
                wrote on last edited by
                #7

                @jsulm
                @Lifetime-Qt-Champion

                Ok Thanks :)

                1 Reply Last reply
                0

                • Login

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