PDA

View Full Version : Create a QImage from a QwtPlot



gib
12th August 2014, 06:54
Hi,
My program has the capability to create a movie from two different sources, one is vtkWindowToImageFilter, the other is QwtPlot. To achieve commonality between these two sources, I want to create a QImage from the QwtPlot. I'm not saying this is the best approach, but I have something that almost works, and it although it may be inefficient I do not have any concerns about speed.

What I have so far is this:

// Create an image
QImage image( qp->canvas()->size(), QImage::Format_RGB32 );
image.fill( QColor( Qt::white ).rgb() ); // guess you don't need this line
QPainter p( &image );
qp->drawCanvas( &p );
p.drawImage( 0, 0, image );

This works, but the image is just of the QwtPlot canvas. I want to find a way to make an image that includes the axes etc. Can someone tell me how to do this? BTW I am using Qwt 5.2.1.

Thanks
Gib

Uwe
12th August 2014, 19:05
See QwtPlotRenderer ( in earlier versions the functionality was available by QwtPlot::print() ).

Uwe

gib
12th August 2014, 21:53
Thanks Uwe. I realized soon after posting my question that I could use QwtPlot::print() (although it does not appear in the class documentation). I'm using Qwt-5.2.1. It's working fine :))

Gib