PDA

View Full Version : QPixmap cannot load data on Windows Mobile 6.1



_Stefan
30th August 2010, 13:52
Hello all!

I have this weird situation, and I can't seem to find the solution myself. Maybe someone has had this problem before or can point me in the right direction.

I have made an application in Qt creator. It loads a JPG from an internet source, and puts it in a QPixmap, which is then displayed by a label. No problem here, it works.

Now, the problem arises, when I compile the same application for Windows Mobile. I have compiled the Qt libraries with Qt everywhere, according to the documentation, all seemed to work. I can also get the app on the phone im using to test and debug the app.

Now, the same code, gives me a problem when I try to load the data into the QPixmap. It is the same JPG and even the data the app gathered looks the same as with the desktop app.

Does anyone have a clue, why this fails on Windows Mobile 6.1?


Here is some code that is called when I have received all the JPG data.
m_imgData is q QByteArray, which does have the same size as in the desktop app, so I guess, this should be ok.


QPixmap img;
img.loadFromData(m_imgData, "JPG"); // returns false on Windows Mobile, not on desktop!! why??
ui.lblImage->setText(m_imgData);

m_imgData.clear();
Reply->deleteLater();


Any ideas?


Grtz,

Stefan

Lykurg
30th August 2010, 14:16
It all sounds like you have not build the jpeg plugin for your mobile or you have it "installed" on a place where your application can't find it.

_Stefan
31st August 2010, 09:24
Thanks for the hint!

It indeed does look like it. When I fetch the supported image types, it does not give me jpg, so that should be enough of a hint.

However, the jpg pluging did build, I have all the DLL, .so and .a files in there. I tried linking in the jpegd4.lib file and deploy the jpegd4.dll, but it still does not recognize it.

Do I have to build Qt all over again, or how can I tell the solution that I want to make use of the plugin? Haven't ever used this before =/

Thanks so far!

_Stefan
31st August 2010, 11:57
Never mind, I figured it out! It works like a charm now.

Just in case anyone was wondering, you need to create a folder where you want to put your plugins in. The name of this folder is irrelevant, but I conveniently named it plugins, just like qt does.

In there, copy the plugins you want to use. So I needed the imageformats plugins:
In my plugins folder, I created the imageformats folder (this time, the name DOES matter, else Qt cannot find them) and I copied all the JPG named files.

Then in your code, after you create your QApplication / QCoreApplication, add the line QApplication::addLibraryPath ("./plugins"); (or QCoreApplication::....).
I have placed the folder plugins in the root of my app.

And now it all works ;)

Thanks again!