Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Unable to load gif file in QImage
Forum Updated to NodeBB v4.3 + New Features

Unable to load gif file in QImage

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 7.7k Views 1 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.
  • S Offline
    S Offline
    spsingh
    wrote on last edited by
    #1

    I am using Qt 4.5 (on VS 2008) which has been built dynamically(debug and release). I have linked my app to the <QTDIR>\plugins\imageformats\qgifd4.lib.

    I create a QImage from a gif file on disk. But the QImage returned is null. I logged the loading of the gif plugin using QT_DEBUG_PLUGINS flag. The gif plugin logs are as below

    'MyApp.exe': Loaded 'C:\Qt\VS45\qt\plugins\imageformats\qgifd4.dll', Symbols loaded.
    'MyApp.exe': Unloaded 'C:\Qt\VS45\qt\plugins\imageformats\qgifd4.dll'

    I also debugged the creation of QImage. In the function createReadHandlerHelper() the code looks like this
    QFactoryLoader *l = loader();
    QStringList keys = l->keys();

    after this when the code searches for the "gif" extension in these keys nothing is found.
    Does it mean that the gif plugin is corrupt? What am I doing wrong? Please help!! I have stuck here for a long time.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vishwajeet
      wrote on last edited by
      #2

      Try this:

      In Qt folder go to <Qt Version Folder>\examples\widgets\imageviewer
      Try to load your gif images thru this application, if they are getting loaded then no prob with your plugin.

      2nd step: Check the gif path in your application. R u loading them from resource file or thru relative path, whatever is the case but using QFileInfo class you can check if the path is valid before u pass that to QImage class.

      Born To Code !!!

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spsingh
        wrote on last edited by
        #3

        The imageviewer is also not able to load gif files. I am loading the files thru absolute path.

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          Yash
          wrote on last edited by
          #4

          Check gif files are ok

          Try to create qrc (qt resource file) Add file into it

          Then load it.

          Also if possible update your version.

          http://kineticwing.com : Web IDE, QSS Editor
          http://speedovation.com : Development Lab

          1 Reply Last reply
          0
          • S Offline
            S Offline
            spsingh
            wrote on last edited by
            #5

            I have upgraded to 4.6.3 , and now the QImage objects loads the gif file properly. But I am unable to render it in a TableView cell. I have a custom model for the view whose data function has the following pseudo code

            QVariant data()
            {
            if (role== displayrole)
            return QVariant(QImage(gifFilePath));
            else
            return QVariant();
            }

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vishwajeet
              wrote on last edited by
              #6

              Start new thread

              Born To Code !!!

              1 Reply Last reply
              0
              • S Offline
                S Offline
                spsingh
                wrote on last edited by
                #7

                After reading the documentation again, I figured out that it should be the decoration role and not the display role for the gif to render.

                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