Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to using GIF image for QT ?
Forum Updated to NodeBB v4.3 + New Features

How to using GIF image for QT ?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
23 Posts 4 Posters 2.9k Views
  • 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.
  • N Offline
    N Offline
    Nguyen Thang Phong
    wrote on last edited by
    #5

    @JonB
    I build qt static to custom installer framework is the path plugins/imageformats/qgif.lib, but when using binary creator to build app.exe using QLabel and QMovie but not display image ?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      See https://doc.qt.io/qt-6/qtplugin.html#Q_IMPORT_PLUGIN and https://doc.qt.io/qt-6/plugins-howto.html#static-plugin on how to use static plugins

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • N Offline
        N Offline
        Nguyen Thang Phong
        wrote on last edited by
        #7

        @Christian-Ehrlicher @JonB
        I added QTPLUSGIN += qgif into installer.pro
        After, I build source installer framework done.
        But I tested not display GIF image.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #8

          My post contains two links...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • N Offline
            N Offline
            Nguyen Thang Phong
            wrote on last edited by
            #9

            @Christian-Ehrlicher

            image.png
            I tried but not working

            1 Reply Last reply
            0
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #10

              Then the path you given to QMovie does not exist. Check it

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • N Offline
                N Offline
                Nguyen Thang Phong
                wrote on last edited by
                #11

                @Christian-Ehrlicher
                I using pixmap to assign direct for GIF image but run not appear ?
                No away to solution ...

                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  Again: Check if the file exists. E.g. with QFile::exists() ...

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    Nguyen Thang Phong
                    wrote on last edited by Nguyen Thang Phong
                    #13

                    @Christian-Ehrlicher @JonB
                    image.png
                    So, check supported image format to print formats bmp,pbm,pgm,png,ppm,xbm,xpm not found gif ?

                    1 Reply Last reply
                    0
                    • JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #14

                      I do not know for sure that GIF should appear in supportedImageFormats(), though I agree I would have thought it should.
                      I suggested earlier that you try to display a GIF as an image on a QLabel, not in a QMovie.
                      @Christian-Ehrlicher asked you to verify that the path to the GIF file you test really does exist via QFile::exists().

                      JoeCFDJ 1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        Nguyen Thang Phong
                        wrote on last edited by
                        #15

                        @Christian-Ehrlicher @JonB
                        image.png
                        I tried add to pixmap

                        JonBJ 1 Reply Last reply
                        0
                        • N Nguyen Thang Phong

                          @Christian-Ehrlicher @JonB
                          image.png
                          I tried add to pixmap

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #16

                          @Nguyen-Thang-Phong
                          I do not use resources and I do not know whether that ../..../additonal.qrc path is right.
                          What does QFile::exists(":/loading.gif") return?
                          If you place a .gif file in your actual file system and try

                          qDebug() << QFile::exists("c:/full/path/to/file.gif");
                          // `label` is some `QLabel *` you have created and is visible in your UI
                          label->setPixmap(new QPixmap("c:/full/path/to/file.gif"));
                          

                          (I think the above is right, untested, adjust as necessary) does that work?

                          Otherwise I guess it is indeed a "static" issue, and only someone like @Christian-Ehrlicher knows what the issue might be.

                          1 Reply Last reply
                          0
                          • JonBJ JonB

                            I do not know for sure that GIF should appear in supportedImageFormats(), though I agree I would have thought it should.
                            I suggested earlier that you try to display a GIF as an image on a QLabel, not in a QMovie.
                            @Christian-Ehrlicher asked you to verify that the path to the GIF file you test really does exist via QFile::exists().

                            JoeCFDJ Offline
                            JoeCFDJ Offline
                            JoeCFD
                            wrote on last edited by JoeCFD
                            #17

                            @JonB I play a GIF file in a QMovie in a QLabel.

                            JonBJ 1 Reply Last reply
                            0
                            • N Nguyen Thang Phong

                              @JonB
                              m_movie = new QMovie(gif);
                              m_label->setMovie(m_movie);
                              m_movie->start();
                              and add QTPLUGIN += qgif into file .pro
                              But not display when check using
                              qDebug() << "supported formats: " << QImageReader::supportedImageFormats();
                              supported formats: QList("bmp", "pbm", "pgm", "png", "ppm", "xbm", "xpm")

                              JoeCFDJ Offline
                              JoeCFDJ Offline
                              JoeCFD
                              wrote on last edited by JoeCFD
                              #18

                              @Nguyen-Thang-Phong Did you try the following in the pro file?

                              CONFIG   += static
                              # For static plugins
                              static {
                                  # Include the GIF plugin
                                  QTPLUGIN += qgif
                              }
                              
                              N 1 Reply Last reply
                              0
                              • JoeCFDJ JoeCFD

                                @JonB I play a GIF file in a QMovie in a QLabel.

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #19

                                @JoeCFD said in How to using GIF image for QT ?:

                                @JonB I play a GIF file in a QMovie in a QLabel.

                                I know you do. And I have suggested removing the QMovie level, to eliminate that, by assigning a created QPixmap from a GIF file directly to the QLabel, which can display GIF images, to see if that works. And I have also suggested using an external, actual GIF file instead of one in a Qt resource, and various QFile::exists() checks to verify the file or resource can be found. Up to you whether you do these things, but they check for various problems. It may well be that your issue is static-related and these will not show anything wrong, but it is what I would do before proceeding.

                                JoeCFDJ 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @JoeCFD said in How to using GIF image for QT ?:

                                  @JonB I play a GIF file in a QMovie in a QLabel.

                                  I know you do. And I have suggested removing the QMovie level, to eliminate that, by assigning a created QPixmap from a GIF file directly to the QLabel, which can display GIF images, to see if that works. And I have also suggested using an external, actual GIF file instead of one in a Qt resource, and various QFile::exists() checks to verify the file or resource can be found. Up to you whether you do these things, but they check for various problems. It may well be that your issue is static-related and these will not show anything wrong, but it is what I would do before proceeding.

                                  JoeCFDJ Offline
                                  JoeCFDJ Offline
                                  JoeCFD
                                  wrote on last edited by
                                  #20

                                  @JonB It is not a QMovie issue. May be better to try to make his code to run dynamically with gif plugin first. And then build his app with gif plugin statically.

                                  JonBJ 1 Reply Last reply
                                  1
                                  • JoeCFDJ JoeCFD

                                    @JonB It is not a QMovie issue. May be better to try to make his code to run dynamically with gif plugin first. And then build his app with gif plugin statically.

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by JonB
                                    #21

                                    @JoeCFD
                                    I understand, but was trying to simplify, and follow @Christian-Ehrlicher's suggestion of checking file exists and removing resources from OP's situation, as I don't know what he actually has there/where.

                                    If you are happy to take over here that's fine :) If the fact that the OP's supportedImageFormats() does not include GIF indicates that is where the problem lies then obviously all my questions are not relevant.

                                    1 Reply Last reply
                                    0
                                    • JoeCFDJ JoeCFD

                                      @Nguyen-Thang-Phong Did you try the following in the pro file?

                                      CONFIG   += static
                                      # For static plugins
                                      static {
                                          # Include the GIF plugin
                                          QTPLUGIN += qgif
                                      }
                                      
                                      N Offline
                                      N Offline
                                      Nguyen Thang Phong
                                      wrote on last edited by
                                      #22

                                      @JoeCFD
                                      Thank you, I will try

                                      1 Reply Last reply
                                      0
                                      • N Offline
                                        N Offline
                                        Nguyen Thang Phong
                                        wrote on last edited by
                                        #23

                                        @Christian-Ehrlicher @JonB @JoeCFD
                                        I have tried the solution, but not GIF image format to work.

                                        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