在我的应用程序中包含 jpeg 插件

发布于 2024-11-24 23:15:47 字数 754 浏览 5 评论 0原文

我制作了一个加载 jpeg 文件的 Qt GUI 应用程序。在我安装了 QtSDK (4.7.3) 的开发系统 (Win7) 上,它可以工作。 当我将应用程序和一些必需的 dll(如 QtGui4.dll 等)移动到另一个未安装 QtSDK 的系统时,程序会执行,但无法加载 jpeg。 我读到,我必须添加 jpeg 插件,但我不知道如何添加。

我已经在我的 main.cpp 中尝试过这个:

Q_IMPORT_PLUGIN(qjpeg);

以及我的项目文件中的这个:

QTPLUGIN += qjpeg

但我收到了错误:

cannot find -lqjpegd

我不关心我是否以动态或静态方式包含此插件。我只需要我的应用程序可以在其他系统上运行。我更喜欢更简单的方式。我尝试的是静态方式,对吗?我怎样才能将它作为 dll 文件包含在我的应用程序中? 我也检查了我的

mingw\plugins\imageformats

目录,确实没有qjpeg.dll。但有:

qjpeg4.dll qjpegd4.dll libqjpeg4.a

比我尝试过:

Q_IMPORT_PLUGIN(qjpeg4);
QTPLUGIN += qjpeg4

但得到了相同的错误消息。怎么了?

感谢您的回答!

I made a Qt GUI application that loads jpeg files. On my development system (Win7) where I have installed the QtSDK (4.7.3) it works.
When I move the application and some required dlls (like QtGui4.dll and others) to another system, where the QtSDK isnt installed, the program executes, but cant load jpegs.
I read, that i have to add the jpeg plugin, but I dont know how.

I already tried this in my main.cpp:

Q_IMPORT_PLUGIN(qjpeg);

together with this in my project file:

QTPLUGIN += qjpeg

But I got the error:

cannot find -lqjpegd

I dont care if I include this plugin in a dynamic or a static way. I just need my application to work on other systems. I prefer the way that is simpler. What I tried is the static way, right? How can I just include it as a dll file in my application ?
I also checked my

mingw\plugins\imageformats

directory and there is really no qjpeg.dll. But there are:

qjpeg4.dll
qjpegd4.dll
libqjpeg4.a

Than i tried it with:

Q_IMPORT_PLUGIN(qjpeg4);
QTPLUGIN += qjpeg4

But got the same error msg. Whats wrong?

Thanks for your answers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋千易 2024-12-01 23:15:47

plugins\imageformats 文件夹复制到您的应用程序目录中。
在你的 main() 中,添加这个

QApplication a(argc, argv);
QString sDir = QCoreApplication::applicationDirPath();
a.addLibraryPath(sDir+"/plugins");

Copy the plugins\imageformats folder into your application directory.
In your main(), add this

QApplication a(argc, argv);
QString sDir = QCoreApplication::applicationDirPath();
a.addLibraryPath(sDir+"/plugins");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文