PDA

View Full Version : How to read and write a float* to mySQL as a BLOB?



agerlach
20th May 2011, 03:30
Howdy!

I need some help being able to read and write float* and unsigned char* as BLOBs in mySQL. I understand how to read and write a QVariant as a BLOB using QT but I'm not sure of the best way to put these arrays into QVariants or how to retrieve a float* or unsigned char* from a QVariant when retrieving the BLOB from the database.

Both the float* and unsigned char* are images output from VTK. I tried doing the following as a test to go to a QVariant and back but the resulting image is not correct (data != dataOut). I'm sure that there has to be a better way to approach this.


QList<unsigned char> *image = new QList<unsigned char>();
for(int i = 0; i < memsize/sizeof(unsigned char); i++)
{
image->append(data[i]);
}

unsigned char *dataOut = image->toVector().data();

high_flyer
20th May 2011, 08:54
Search the forum for BLOB.
There are several threads about similar issues, I think mostly about images, but the principals should be the same.