Write Qt in the past few daysProgramWhen a problem occurs, the GIF of the locally compiled application is displayed normally, but only PNG can be displayed normally when moved to another machine, but GIF and jpg cannot be displayed. at first, we thought it was the relationship of the resource package, and then thought it was the path. Finally, we found it was actually the relationship of the plug-in.
Under the QT directory, there is a directory such as plugins/imageformats, which contains qgif. DLL, qini4.dll, and other dynamic link libraries. When QT is installed on the machine, these libraries can be successfully called, so the local GIF can be properly displayed, images cannot be displayed because these library files cannot be found when moving to other machines without QT installed.
The solution is as follows:
Create the plugins/imageformats folder under the application directory, copy the required image support plug-in, and then add qapplication A (argc, argv) in the program source file main. cpp.CodeQapplication: addlibrarypath ("./plugins"); it looks like this:
Int main (INT argc, char * argv [])
{
Qapplication: addlibrarypath ("./plugins ");
Qapplication A (argc, argv );
Qtalltest W;
W. Show ();
Return a.exe C ();
}
OK !!