Results 1 to 3 of 3

Thread: Save qpixmap to file

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Post Save qpixmap to file

    Ok, now I can retrieve a icon from a file. How can I save it to a xml file?
    Ex:
    Qt Code:
    1. <icon>
    2. <name>Explorer<name/>
    3. <iconData> 011001010110101001001010110010101001110101110011
    4. 011001010110101001001010110010101001110101110011
    5. 011001010110101001001010110010101001110101110011
    6. 011001010110101001001010110010101001110101110011
    7. 011001010110101001001010110010101001110101110011
    8. 011001010110101001001010110010101001110101110011
    9. 011001010110101001001010110010101001110101110011
    10. 011001010110101001001010110010101001110101110011
    11. 011001010110101001001010110010101001110101110011
    12. 011001010110101001001010110010101001110101110011
    13. <iconData/>
    14. <icon/>
    To copy to clipboard, switch view to plain text mode 

    Thanks for all the help!

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

    Default Re: Save qpixmap to file

    you can use this code for Qt Assistant to save a pixmap in a QBuffer
    Qt Code:
    1. ...
    2. QPixmap pixmap;
    3. QByteArray bytes;
    4. QBuffer buffer(&bytes);
    5. buffer.open(QIODevice::WriteOnly);
    6. pixmap.save(&buffer, "PNG");
    7. ...
    To copy to clipboard, switch view to plain text mode 
    then you can convert QByteArray to base64 (using QByteArray::toBase64) and store in xml.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following 2 users say thank you to spirit for this useful post:

    AcerExtensa (12th June 2009), nightghost (18th April 2011)

  4. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Save qpixmap to file

    Thank you.

Similar Threads

  1. How to save file with QFileDialog
    By pnikolov in forum Qt Programming
    Replies: 11
    Last Post: 1st June 2012, 10:23
  2. Rendering QGraphicsScene to QPixmap to save
    By Rooster in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2009, 05:24
  3. How set default file to save in QFileDialog
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 12:09
  4. Restrict user from entering space in Save As File Name
    By jyoti kumar in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 12:47
  5. How to check a file for changes since last save
    By nmather in forum General Programming
    Replies: 2
    Last Post: 21st April 2007, 23:43

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.