开发者

loading standard qt plugins MANUALLY and dynamically

开发者 https://www.devze.com 2023-01-29 03:20 出处:网络
Can anyone please give an example of HOW TO LOAD qjpeg or any other standard QT plugin manually. Please give a CODE EXAMPLE, Not a link to qt pages because I already know the following facts:

Can anyone please give an example of HOW TO LOAD qjpeg or any other standard QT plugin manually. Please give a CODE EXAMPLE, Not a link to qt pages because I already know the following facts:

  1. I am not linking qt as static lib.
  2. I know how to deploy standard qt plugins (this is the automatic part) 2.1. for qjpeg you copy qjpeg4.dll to ./i开发者_如何学编程mageformats/qjpeg4.dll as . being the base dir of your app. but I want to load and use qjpeg lib.

as in

QPluginLoader loader("qjpeg4.dll");
if (loader.instance()) {
    cout << "ok" << endl;
} else {
    cout << "fail" << endl << loader.errorString().toStdString() << endl;
}


QList<QByteArray> list = QImageReader::supportedImageFormats();
for (int i = 0; i < list.size(); ++i) {
    f << list.at(i).constData() << std::endl;
}

this does not print jpg and jpg images cannot be read and written. Maybe if someone adds something more here it will work. or maybe I am copletely wrong.


I haven't done this but here is an educated guess, you are probably doing the right thing to load the plugin but by not going the normal route the QImageReader does not actually know about the plugin being available. If you really need to explicitely load you plugin, you can probably cast the result of QPlugiLoader::instance() to a QImageIOPlugin and using the QIOImageHandler to read your jpgs, but it looks like you would have to forgo using the QImageReader

0

精彩评论

暂无评论...
验证码 换一张
取 消