PDA

View Full Version : Export QwtPlot to png file with help print



maxomato
3rd March 2011, 10:05
Hi.

I try to export QwtPlot to png file. I use this function



void XTrendViewer::makeExport( const QString& fileName )
{
QPicture picture;
QwtPlot::print( picture );

QPixmap pixmap( 800, 600 );
pixmap.fill();

QPainter painter( &pixmap );
painter.drawPicture( 0,0, picture );
painter.end();
pixmap.save( fileName );
}


But I am getting file with white space without image. How to export/save qwtPlot into png, jpg and etc.

maxomato
4th March 2011, 08:34
Problem is solved. I used qwt 5.2.1 in past and there was this problem. Now I am using qwt 6.0 and class QwtPlotRenderer. Print and export work fine.

But example "body" from new version qwt ( 6.0 ) has not worked when I had tried to export QwtPlot into SVG. In my code I use method QwtPlotRenderer.renderTo and QSvgGenerator for the export.

In example "body" method QwtPlotRenderer.renderDocument is using for this export.