How to using GIF image for QT ?
-
wrote 27 days ago last edited by
QT : 6.7.3
Installer Framework : 4.9
MSVC : 2022
1. Step build QT Static- git clone https://code.qt.io/qt/qt5.git
- set PATH=C:\Phong\Libraries\Strawberry\perl\bin;%PATH%
- cd qt5
- git checkout 6.7.3
- perl init-repository --module-subset=qtbase,qtsvg,qtdeclarative,qttools,qt5compat
- set INCLUDE=C:\Phong\Libraries\MSVC\VC\Tools\MSVC\14.43.34808\atlmfc\include;%INCLUDE%
- C:\Phong\Libraries\MSVC\setup_x64.bat
- configure -static -prefix C:\Phong\Libraries\Qt-Static -opensource -confirm-license -qt-libpng -qt-libjpeg -qt-zlib -gif
- cmake --build . --parallel
- cmake --install . --prefix C:\Phong\Libraries\Qt-Static
2. Step build QT installer framework - git clone https://github.com/qtproject/installer-framework.git
- cd installer-framework
- git checkout 4.9
- C:\Phong\Libraries\MSVC\setup_x64.bat
- set PATH=C:\Phong\Libraries\Qt-Static\bin;%PATH%
- set LIB=C:\Phong\Libraries\Qt-Static\lib;%LIB%
- set INCLUDE=C:\Phong\Libraries\Qt-Static\include;%INCLUDE%
- qmake -r
- nmake
When using QMovie for GIF image, image not display ?
-
QT : 6.7.3
Installer Framework : 4.9
MSVC : 2022
1. Step build QT Static- git clone https://code.qt.io/qt/qt5.git
- set PATH=C:\Phong\Libraries\Strawberry\perl\bin;%PATH%
- cd qt5
- git checkout 6.7.3
- perl init-repository --module-subset=qtbase,qtsvg,qtdeclarative,qttools,qt5compat
- set INCLUDE=C:\Phong\Libraries\MSVC\VC\Tools\MSVC\14.43.34808\atlmfc\include;%INCLUDE%
- C:\Phong\Libraries\MSVC\setup_x64.bat
- configure -static -prefix C:\Phong\Libraries\Qt-Static -opensource -confirm-license -qt-libpng -qt-libjpeg -qt-zlib -gif
- cmake --build . --parallel
- cmake --install . --prefix C:\Phong\Libraries\Qt-Static
2. Step build QT installer framework - git clone https://github.com/qtproject/installer-framework.git
- cd installer-framework
- git checkout 4.9
- C:\Phong\Libraries\MSVC\setup_x64.bat
- set PATH=C:\Phong\Libraries\Qt-Static\bin;%PATH%
- set LIB=C:\Phong\Libraries\Qt-Static\lib;%LIB%
- set INCLUDE=C:\Phong\Libraries\Qt-Static\include;%INCLUDE%
- qmake -r
- nmake
When using QMovie for GIF image, image not display ?
wrote 27 days ago last edited by@Nguyen-Thang-Phong
Can you display the GIF image in, say, aQLabel
rather than aQMovie
? -
wrote 27 days ago last edited by 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") -
@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 JonB@Nguyen-Thang-Phong Per https://forum.qt.io/topic/53280/qmovie-gif-and-qrc where is your
qgif.dll
? Assuming that is still needed for Qt6. -
wrote 27 days ago last edited by
@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 ? -
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
-
wrote 27 days ago last edited by
@Christian-Ehrlicher @JonB
I added QTPLUSGIN += qgif into installer.pro
After, I build source installer framework done.
But I tested not display GIF image. -
My post contains two links...
-
wrote 27 days ago last edited by
-
Then the path you given to QMovie does not exist. Check it
-
wrote 26 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 26 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 26 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 26 days ago last edited by
@Christian-Ehrlicher @JonB
I tried add to pixmap -
@Christian-Ehrlicher @JonB
I tried add to pixmapwrote 26 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 26 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 26 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.
8/23