Results 1 to 13 of 13

Thread: how to save a image file ( say png ) into mysql database?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to save a image file ( say png ) into mysql database?

    i tried the same but it didnt worked.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: how to save a image file ( say png ) into mysql database?

    it works fine for me. what did you try?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    May 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to save a image file ( say png ) into mysql database?

    i am doing it following way..

    say have an image file named: apple.png
    i opened the file and read it completely using file.readAll(). and saved it into QString (str).
    then i converted this QString(str) into QbyteArray and then called toBase64(). and then tried to save it in database and in same way i tried to read it from database but it didnt worked.

    Can you share your sample code for this?

    thanx

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: how to save a image file ( say png ) into mysql database?

    why are you saving data to QString and then converting it to QByteArray? isn't readAll() alredy returning QByteArray? try to readAll() straight into QByteArray without any QStirings
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    May 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to save a image file ( say png ) into mysql database?

    its not working for me

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: how to save a image file ( say png ) into mysql database?

    can you show us your code?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #7
    Join Date
    Sep 2009
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    4
    Thanked 5 Times in 5 Posts

    Default Re: how to save a image file ( say png ) into mysql database?

    Save given QImage directly into QByteArray:

    Qt Code:
    1. QImage image;
    2. QBuffer buffer(&ba);
    3. buffer.open(QIODevice::WriteOnly);
    4. image.save(&buffer, "PNG");
    To copy to clipboard, switch view to plain text mode 
    (Taken from Documentation)

Similar Threads

  1. Putting and getting images from MySQL database?
    By allensr in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2007, 21:47
  2. Qt and MySQL Database Connection
    By shamik in forum Qt Programming
    Replies: 41
    Last Post: 6th October 2006, 12:48
  3. Replies: 7
    Last Post: 12th August 2006, 15:11
  4. Issues regarding QMySql drivers and mysql database
    By bera82 in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2006, 17:50
  5. Replies: 8
    Last Post: 7th March 2006, 13:40

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
  •  
Qt is a trademark of The Qt Company.