Results 1 to 3 of 3

Thread: Saving Plots as an image file (png, bmp etc.)

  1. #1
    Join Date
    Mar 2009
    Posts
    5
    Thanked 1 Time in 1 Post

    Default Saving Plots as an image file (png, bmp etc.)

    Hi,

    I have a problem while saving a Qwt plot as an png image.
    I use QPixmap::grabWidget method but only some part of the plot
    is written to png file (only label texts and title), and the plot itself is not written to png file...
    I added snapshots of original plot and saved plot. Any idea to fix the problem?


    Qt Code:
    1. int main(int argc, char **argv)
    2. {
    3. QApplication a(argc, argv);
    4.  
    5. Plot plot;
    6. #if QT_VERSION < 0x040000
    7. a.setMainWidget(&plot);
    8. #endif
    9. plot.resize(600,400);
    10. plot.show();
    11.  
    12. QPixmap p = QPixmap::grabWidget(&plot, 0, 0, plot.width(), plot.height());
    13. p.save("C:\\plot.png","png");
    14.  
    15. return a.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Saving Plots as an image file (png, bmp etc.)

    Did you try using QwtPlot::print()?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2009
    Location
    San José, Costa Rica
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Saving Plots as an image file (png, bmp etc.)

    Had a similar problem creating a Pixmap. The curves dis not show until I used replot().
    Include this coimmand after show(). Hope it works.

Similar Threads

  1. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 18:02
  2. Saving QGraphicsScene with OpenGL to image
    By elbaschid in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2009, 21:32
  3. Saving QLabel content in a file
    By Caius Aérobus in forum Newbie
    Replies: 1
    Last Post: 29th October 2008, 18:03
  4. Can't Write Image as Jpeg file
    By noufalk in forum Qt Programming
    Replies: 4
    Last Post: 25th July 2007, 15:53
  5. Saving already opened image ...
    By Godlike in forum Newbie
    Replies: 14
    Last Post: 28th March 2006, 22:17

Tags for this Thread

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.