Results 1 to 2 of 2

Thread: How to read and write a float* to mySQL as a BLOB?

  1. #1
    Join Date
    May 2010
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to read and write a float* to mySQL as a BLOB?

    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.
    Qt Code:
    1. QList<unsigned char> *image = new QList<unsigned char>();
    2. for(int i = 0; i < memsize/sizeof(unsigned char); i++)
    3. {
    4. image->append(data[i]);
    5. }
    6.  
    7. unsigned char *dataOut = image->toVector().data();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to read and write a float* to mySQL as a BLOB?

    Search the forum for BLOB.
    There are several threads about similar issues, I think mostly about images, but the principals should be the same.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 2
    Last Post: 2nd November 2010, 05:15
  2. Issues when binding a QByteArray as a BLOB in MySQL
    By agerlach in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2010, 12:43
  3. Inserting blob into mysql using QT?
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 31st August 2010, 04:37
  4. How to insert BLOB into MySQL with Qt?
    By babygal in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2010, 12:26
  5. problem with read blob from postgres db
    By zlatko in forum Qt Programming
    Replies: 4
    Last Post: 5th November 2006, 08:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.