Displaying a jpg image with Qt does not work with release executable

I have an annoying problem displaying jpg images with qt. I am devlope with Visual Studio 2008 on Windows 7 and using Qt version 4.8.2. Now I will describe my problem using the example "collidingmice" deliverd with Qt (../examples/graphicsview/collidingmice).

I can build this example using the Visual Studio IDE or using the Visual Studio command line. In this example, jpg is used as the background and displays correctly when I execute the debug executable. But in the build release this jpg background is not displayed.

I already realized that Qt uses plugins to load / display different images. Therefore, I copied the contents of the Qt plugin folder to the application directory (where collidingmice.exe is). Unfortunately, this does not solve the problem.

Therefore, I thought that there should be something wrong in the Qt assembly and in the jpeg library. Therefore, I reconfigured Qt by running the following commands at the Visual Studio command prompt:

nmake distclean configure -debug-and-release -opensource -platform win32-msvc2008 -qt-libjpeg -no-webkit nmake 

After that, the example was restored, but again the jpg image is not displayed. I'm not sure what the problem is, as it works in debug builds and in release. I think I need to provide only the necessary DLL modules. But obviously I'm wrong.

I hope someone can help me or can give me some clues where the problem might be. Thanks!

+4
source share
1 answer

Therefore, I copied the contents of the Qt plugin folder to the application directory (where collidingmice.exe is).

You need to put the plugins in the "imageformats" subdirectory, for example. as

 bin ├── collidingmice.exe └── imageformats ├── qjpeg4.dll ├ ... 

See also http://www.qtcentre.org/threads/46927-Location-of-imageformats-directory


It turned out that the OP had already set up the directory structure. The main reason was that the incorrect QtGui4.dll file was loaded. This can be fixed "by copying the DLL directly to the application directory or changing the order of the paths in the PATH environment variable so that your Qt bin directory is placed in front of all other paths containing QtGui4.dll."

In any case, Process Monitor is a good tool to track such problems.

+7
source

Source: https://habr.com/ru/post/1438652/


All Articles