Displaying GIF images from database BLOBs
-
wrote on 2 May 2020, 07:09 last edited by Tharoux 5 Feb 2020, 20:15
EDIT:
I got my engineering brother to look this and he found a solution.
My old SQL query was
SELECT image FROM databaseTable;
but that was losing some information for some reason. Changing this query to
SELECT hex(image) FROM databaseTable;
and the QByteArray below to
QByteArray outByteArray = QByteArray::fromHex(SQLquery.value(0).toByteArray());
fixed it.
Thanks to @mrjj and @Christian-Ehrlicher for helping me, even though I'm such a noob :>
Hi, I'm rather new to Qt and c++ so please bare with me.
I'm trying to retrieve a bunch of GIF images from SQLite database (they're in BLOB form). I've tried using the example from here but for some reason the
outPixmap.loadFromData( outByteArray );
part always fails, leaving the outPixmap to be a null QPixmap.
Here's the problem part of my code://Get image from database BLOB. QByteArray outByteArray = SQLquery.value(0).toByteArray(); QPixmap outPixmap; outPixmap.loadFromData(outByteArray); //Above results in null QPixmap. //Create label for the image. QLabel *tempImgLabel = new QLabel(); tempImgLabel->setPixmap(outPixmap); //This will be a 0x0 label because outPixmap is null.
Thanks for help in advance, noob out.
-
Lifetime Qt Championwrote on 2 May 2020, 07:58 last edited by mrjj 5 Feb 2020, 07:59
Hi and welcome to the forums
What did save the gifs blob ?
Unless also done with Qt and ByteArray then
it wont work :)So its very important how the gif became blobs in the database as the reverse of that has to happen.
-
Hi and welcome to the forums
What did save the gifs blob ?
Unless also done with Qt and ByteArray then
it wont work :)So its very important how the gif became blobs in the database as the reverse of that has to happen.
-
Please show the complete query code, also you can try to save the QByteArray into a QFile and inspect this to see if it contains the correct data.
1/4