How to using GIF image for QT ?
-
My post contains two links...
-
wrote 28 days ago last edited by
-
Then the path you given to QMovie does not exist. Check it
-
wrote 28 days ago last edited by
@Christian-Ehrlicher
I using pixmap to assign direct for GIF image but run not appear ?
No away to solution ... -
Again: Check if the file exists. E.g. with QFile::exists() ...
-
wrote 28 days ago last edited by Nguyen Thang Phong 4 Jan 2025, 07:08
@Christian-Ehrlicher @JonB
So, check supported image format to print formats bmp,pbm,pgm,png,ppm,xbm,xpm not found gif ? -
wrote 28 days ago last edited by JonB 4 Jan 2025, 07:20
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 aQLabel
, not in aQMovie
.
@Christian-Ehrlicher asked you to verify that the path to the GIF file you test really does exist viaQFile::exists()
. -
wrote 28 days ago last edited by
@Christian-Ehrlicher @JonB
I tried add to pixmap -
@Christian-Ehrlicher @JonB
I tried add to pixmapwrote 28 days ago last edited by@Nguyen-Thang-Phong
I do not use resources and I do not know whether that../..../additonal.qrc
path is right.
What doesQFile::exists(":/loading.gif")
return?
If you place a.gif
file in your actual file system and tryqDebug() << 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.
-
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 aQLabel
, not in aQMovie
.
@Christian-Ehrlicher asked you to verify that the path to the GIF file you test really does exist viaQFile::exists()
. -
@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")wrote 27 days ago last edited by JoeCFD 4 Jan 2025, 14:05@Nguyen-Thang-Phong Did you try the following in the pro file?
CONFIG += static # For static plugins static { # Include the GIF plugin QTPLUGIN += qgif }
-
wrote 27 days ago last edited by
@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 createdQPixmap
from a GIF file directly to theQLabel
, 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 variousQFile::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. -
@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 createdQPixmap
from a GIF file directly to theQLabel
, 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 variousQFile::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. -
@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.
wrote 27 days ago last edited by JonB 4 Jan 2025, 13:15@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. -
@Nguyen-Thang-Phong Did you try the following in the pro file?
CONFIG += static # For static plugins static { # Include the GIF plugin QTPLUGIN += qgif }
wrote 27 days ago last edited by@JoeCFD
Thank you, I will try -
wrote 27 days ago last edited by
@Christian-Ehrlicher @JonB @JoeCFD
I have tried the solution, but not GIF image format to work.
17/23