无法在Qt应用程序中加载嵌入式JPG资源 [英] Embedded JPG resources not loading in Qt application

查看:240
本文介绍了无法在Qt应用程序中加载嵌入式JPG资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Qt应用程序,其中包含一些要显示的嵌入式JPG文件。当我在计算机上编译并运行调试版本和发行版时,一切都可以正常运行。当我将应用程序复制到拇指驱动器并在计算机上从那里运行时,它可以正常工作。在拇指驱动器和其他开发人员的计算机上:确定。在第三台非开发人员的计算机上的拇指驱动器上:没有图像

I have a Qt application that has some embedded JPG files that I want to display. When I compile and run both the debug and release versions on my machine, everything works perfectly. When I copy the application to a thumb drive and run it from there on my machine, it works fine. On the thumb drive and another developer's machine: OK. On the thumb drive on a third, non-developer's machine: no images!

proj.pri
RESOURCES += ./proj.qrc

proj.qrc:
<RCC>
<qresource prefix="/myApp">
    <file>Gui/Resources/logo.jpg</file>
    <file>Gui/Resources/another_image.jpg</file>
</qresource>
</RCC>

main.cpp:
{
    ...
    QImage *logo  = new QImage( ":/myApp/Gui/Resources/logo.jpg" );
    QImage *image = new QImage( ":/myApp/Gui/Resources/another_image.jpg" );

    myClass *d1 = new myClass( "Some Text", 48, 30, logo );
    myClass *d2 = new myClass( "Some More Text", 48, 30, another_image );
    ...
}

我已经确认正在添加图像通过在.pri文件中的RESOURCES行中注释掉该可执行文件。二进制文件的大小将减少图像的大小再加上一点;当我运行该应用程序时,图像不会出现。我取消对RESOURCES行的注释,一切都如上所述进行了操作。

I have confirmed that the images are being added to the executable by commenting out the RESOURCES line in the .pri file. The size of the binary drops by the size of the images plus a bit; when I run the application, the images do not appear. I un-comment the RESOURCES line and everything works as described above.

我在这里缺少什么?非开发人员计算机上的DLL? A

What am I missing here? A DLL on the non-developer's machine? A

环境


  • Win XP

  • Qt 4.6.1

  • Visual Studio 2008

  • Qt Creator 1.3.1

  • Win XP
  • Qt 4.6.1
  • Visual Studio 2008
  • Qt Creator 1.3.1

推荐答案

需要jpeg插件才能加载图像。如果安装了Qt,它们将采用%QTDIR%\plugins\imageformats。

It needs jpeg plugin to load images. If you have Qt installed they would be in %QTDIR%\plugins\imageformats.

将qjpeg4.dll复制到拇指驱动器上的plugin文件夹中。

Copy qjpeg4.dll into plugin folder on your thumb drive.

root/app.exe
root/qt.conf
root/plugins/imageformats/qjpeg4.dll

在qt.conf文件中设置插件目录的路径:

In qt.conf file set path to your plugins dir:

[Paths]
plugins=./plugins

这篇关于无法在Qt应用程序中加载嵌入式JPG资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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