Results 1 to 3 of 3

Thread: Problem with qwt6 and saving plot as image

  1. #1
    Join Date
    Nov 2011
    Location
    Łódź, Poland
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Problem with qwt6 and saving plot as image

    Hello,

    I wanted to save a plot as an image and I have a problem with that. I found QwtPlotRender class and renderDocument() method but isn't work as I expected. Small example explain what I mean.

    Qt Code:
    1. QwtPlot *plot = new QwtPlot(this);
    2. plot->setTitle(trUtf8("Tytuł nowy"));
    3.  
    4. QwtPlotCurve *curve_samples = new QwtPlotCurve();
    5. curve_samples->attach(plot);
    6. curve_samples->setRawSamples(x, y, 100);
    7. curve_samples->setTitle("Title of cuvere_sample");
    8. curve_samples->setPen(QPen(QColor(Qt::red)));
    9. curve_samples->setCurveAttribute(QwtPlotCurve::Fitted, true);
    10.  
    11. plot->setAxisTitle(QwtPlot::xBottom, "test");
    12.  
    13. ui->verticalLayout->addWidget(plot);
    14.  
    15. QwtPlotRenderer *renderer = new QwtPlotRenderer();
    16. renderer->renderDocument(plot, "/home/discovery/test.png", QSizeF(150, 100));
    To copy to clipboard, switch view to plain text mode 

    The problem is with QwtPlotCurve, samples are not saved on image.

    app_window.jpg
    Plot in my application.
    test.png
    Plot saved in png file.

    Did I do something wrong? I am quite beginner with qwt library

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem with qwt6 and saving plot as image

    Quote Originally Posted by discovery View Post
    Did I do something wrong?
    You have to do a replot before you call the renderer.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    discovery (12th November 2011)

  4. #3
    Join Date
    Nov 2011
    Location
    Łódź, Poland
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Problem with qwt6 and saving plot as image

    Of course! Thank you so much for help, I have spend several hours today on googling to find solution.

Similar Threads

  1. Replies: 2
    Last Post: 5th May 2010, 07:01
  2. Problem saving JPG image
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 31st July 2009, 16:38
  3. Saving qwt plot as image
    By giusepped in forum Qwt
    Replies: 13
    Last Post: 14th July 2009, 08:39
  4. Saving pure plot data to image file
    By Debilski in forum Qwt
    Replies: 4
    Last Post: 7th April 2009, 18:02
  5. Problem saving a plot
    By kalos80 in forum Qwt
    Replies: 2
    Last Post: 10th July 2008, 09:31

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.