用Qt显示JPG图像不能与发布可执行文件一起使用 [英] Showing JPG image with Qt does not work with release executable

查看:531
本文介绍了用Qt显示JPG图像不能与发布可执行文件一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个恼人的问题,用qt显示jpg图像。我使用Visual Studio 2008在Windows 7和使用Qt版本4.8.2。我现在将通过collidingmice示例deliverd与Qt(../ examples / graphicsview / collidingmice)描述我的问题。

i have a annoying issue with showing jpg images with qt. I devlope with Visual Studio 2008 in Windows 7 and using the Qt version 4.8.2. I will now describe my problem by means of the "collidingmice" example deliverd with Qt (../examples/graphicsview/collidingmice).

我可以通过Visual Studio IDE或通过Visual Studio命令提示符。在本示例中,jpg用作背景,并且在执行调试可执行文件时正确显示。但是在发布版本中,这个背景jpg没有显示。

I can build this example via Visual Studio IDE or with via the Visual Studio command prompt. In this example a jpg is used as background and is correctly shown when I execute the debug executable. But in release build this background jpg is not shown.

我已经意识到,Qt使用插件加载/显示不同的图像。因此,我将Qt的plugin文件夹的内容复制到应用程序目录(collidingmice.exe所在的位置)。不幸的是,这不能解决问题。

I already realized, that Qt uses plugins for loading/showing different images. Therefore I copied the contents of the plugin folder of Qt into the application directory (where collidingmice.exe is). Unfortunatly, this does not solve the problem.

因此,我认为Qt build和jpeg库肯定有问题。因此,我通过在Visual Studio命令提示符中执行以下命令重新配置Qt:

Hence, I thought there must be something wrong with the Qt build and the jpeg library. Therefore, I reconfigured Qt by executing the following commands in the Visual Studio command prompt:

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

之后做了一个重建的例子,但是jpg图像又没有显示。我不知道什么问题是,因为它工作在调试生成和发布我认为我只需要提供所需的插件DLL。但显然我是不对的。

After that did a rebuild of the example, but again the jpg image is not shown. I am not sure what the problem is since it works in debug build and in release I think I only have to deliver the needed plugin DLLs. But obviously I am not right.

我希望任何人都可以帮助我,或者可以给我一些提示问题可能在哪里。谢谢!

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

推荐答案


因此,我将Qt的plugin文件夹的内容复制到$ b $

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

您需要将插件放到imageformats子目录中,例如像

You need to put the plugins into an "imageformats" subdirectory, e.g. like

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

另请参阅http://www.qtcentre.org/threads/46927-Location-of-imageformats-directory

原来,OP已经相应地设置了目录结构。根本原因是,一个错误的QtGui4.dll已经加载。这可以通过将DLL直接复制到应用程序目录中或通过更改PATH环境变量中的路径顺序来修复,以便将Qt bin目录放在包含QtGui4.dll的所有其他路径的前面。

It turned out that the OP had already set up the directory structure accordingly. The root cause was that a wrong QtGui4.dll has been loaded. This can be fixed "by copying the DLL directly into the application directory or by 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 a QtGui4.dll."

无论如何, Process Monitor 是跟踪此类问题的好工具。

In any case, the Process Monitor is a good tool to track down such issues.

这篇关于用Qt显示JPG图像不能与发布可执行文件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆