PDA

View Full Version : QPixmap working on one PC, not another



ShamusVW
9th June 2016, 16:21
Hi all
I am using QPixmap to load a blob/image from a database.
On one PC it works fine, however on a second PC not.
I did some troubleshooting, and it seems that on both PC's it is getting the data correctly from the database, however, on the QPixmap loadFromData function, it is returning false from the second PC.
The troubleshooting I did was to see if on the second PC it was failing on the query, however I am able to get the same ba.size() (the QbyteArray) from both of them.
I did initially try setting the header to jpg, but again without the second one showing an image (on a QLabel), so I just left it as default.
Can someone offer some clue why it would work differently on 2 PC's? Obviously the exact same executable, however on the one PC where it is working I am running Windows 8, on the 2nd I am running Windows Embedded (7).

This is the code I am using...



QByteArray ba = query.value(0).toByteArray();
outPixmap = QPixmap();
outPixmap.loadFromData(ba);
return outPixmap;


Unfortunately I am leaving work now, but I will be back in the morning.
Thank you.

anda_skoa
9th June 2016, 17:43
Have you already checked if two versions have the same supported image formats?

Cheers,
_

ShamusVW
10th June 2016, 07:28
Thank you for the reply.
The image format is jpg, whether I include this in the header or not has the same outcome, i.e. showing on one PC, not the 2nd.
Also, with both operating systems being Windows, I would think this is a standard format that is supported.
If I save the data directly to a file, both PC's can open it through Windows Explorer.
Is there possibly a separate library/dll that I should be including to tell Qt itself to recognise it as a jpg?

Lesiok
10th June 2016, 07:56
JPG is supported by Qt plugin - look at plugins/imageformats Qt directory.

ShamusVW
10th June 2016, 08:18
Thank you, I found someone else with the same issue on
http://www.qtcentre.org/threads/28338-QPixmap-not-loading-image(from-file)-after-deployment

I had to create a folder called imageformats under my executable folder, and copy the dll called qjpeg.dll to it and then it worked.

anda_skoa
10th June 2016, 19:02
Is there possibly a separate library/dll that I should be including to tell Qt itself to recognise it as a jpg?

Yes, that's why I asked if you had already checked.
As in looked at the list returned by http://doc.qt.io/qt-5/qimagereader.html#supportedImageFormats

Cheers.
_