Results 1 to 3 of 3

Thread: Problem saving a plot

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem saving a plot

    Hi,

    I'm saving a plot to an image file using the QwtPlot print function.
    The problem is that the saved image has a bad black margin (see the image attached).

    This is the code I'm using to save the plot image. I'm using Qt 3.3.7 on Windows

    Qt Code:
    1. void MyPlot::savePlot(const QString &sOutputFilename, int w, int h)
    2. {
    3. // get the plot pixmap
    4. QPixmap plotPxm(w, h);
    5. print(plotPxm);
    6.  
    7. plotPxm.save(sOutputFilename, "PNG");
    8. }
    To copy to clipboard, switch view to plain text mode 


    How can I solve the problem?

    Thank you in advance for your help.
    Attached Images Attached Images

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

    Default Re: Problem saving a plot

    a) I recommend to export into better formats like PDF or SVG ( without using a pixmap in between).
    b) Your pixmap is not initialized. Add plotPxm.fill(...) before you print on it.

    HTH,
    Uwe

  3. #3
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problem saving a plot

    Uwe, Thank you very much for your hint, it works!

    I tried to save the plot is SVG and it looks better, but unfortunatly I need to save it as a JPEG/PNG image, so I have to leave it the way it is now.

    Thanks again!

Similar Threads

  1. Reg multiple plots in Qwt
    By Tavit in forum Qwt
    Replies: 4
    Last Post: 23rd June 2008, 13:43
  2. setScaleAxis(), setScaleDiv() problem..
    By halberdier83 in forum Qwt
    Replies: 1
    Last Post: 4th April 2008, 08:02
  3. Qwt plot problem on compile
    By sincnarf in forum Qwt
    Replies: 2
    Last Post: 14th October 2007, 11:36
  4. My scientific plot problem
    By baray98 in forum Qt Programming
    Replies: 2
    Last Post: 5th August 2007, 15:01
  5. problem with saving QCstrings
    By nass in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2006, 15:12

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.