Results 1 to 2 of 2

Thread: How to export the QWT Plot as png file with preserve the plot aspect raio??

  1. #1
    Join Date
    Feb 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Windows

    Question How to export the QWT Plot as png file with preserve the plot aspect raio??

    Hi Friends,

    i am facing the problem while export the qwt plot as the png image....

    the problem is : in the saved "export.png" image...it is not preserving the aspect ratio(i.e if we check the 0 to 0.1 in x & y direction it is not same)... but i want to maintain the same distance in x & y direction.

    it is correctly maintaining in the widget..please refer "plotwidget.png"...

    my code snippet for export the qwt plot into png file:

    const double scaleFactor = 2.0;
    const QSize sz(800,640);
    QString saveFileName="airfoilgeom.png";
    QwtPlotRenderer renderer;
    QString windirpath = dirpath.replace("/","\\");

    QImage image0(sz, QImage::Format_ARGB32);
    image0.fill( QColor( Qt::white ).rgb() );
    QPainter painter0(&image0);
    painter0.scale(scaleFactor, scaleFactor);

    renderer.setDiscardFlag(QwtPlotRenderer:iscardBackground, false);
    renderer.setLayoutFlag(QwtPlotRenderer::KeepMargin s, true);
    renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames , true);
    renderer.render(airfoilgeomplots.at(j), &painter0, QRectF(QPointF(0, 0),sz / scaleFactor));
    image0.save(windirpath+"\\LSWT_Report\\Report\\Plo ts\\"+saveFileName);

    can anyone help me to solve the problem?????

    Thanks & Regards,
    Muthulingam
    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: How to export the QWT Plot as png file with preserve the plot aspect raio??

    There is no satisfying solution for this problem - the reason is the layout engine of QwtPlot and how it works.
    But maybe you can render a pdf document ( vector graphics ! ) and scale the result in a second step to have the aspect ratio you need.

    Uwe

Similar Threads

  1. Replies: 5
    Last Post: 11th June 2011, 15:29
  2. Plot -> image file
    By gib in forum Qwt
    Replies: 1
    Last Post: 8th April 2010, 06:30
  3. export and printing qwt plot
    By giusepped in forum Qwt
    Replies: 6
    Last Post: 17th December 2008, 07:04
  4. export a plot as image
    By giusepped in forum Qwt
    Replies: 0
    Last Post: 16th December 2008, 14:43
  5. Replies: 7
    Last Post: 22nd September 2008, 22:05

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.