Maximus2
29th January 2015, 22:30
I have a custom QwtPlot that I want to render inside a pdf document. (see use-case image) (https://www.dropbox.com/s/2hdu00g8rrdtu6k/qwtPlotReport.png?dl=0)
QwtPlotRenderer looks to be perfect for doing this, the only thing is that I need to edit a few thing on the Plot before rendering it.
Right now I just modify the original plot directly before rendering it, which cause the interface to also be modified.
Here is an example :
void WorkoutCreator::exportWorkoutToPdf() {
/// TODO: Add Title, remove background image, increase margins
ui->widget_plot->setContentsMargins(20,20,20,20);
QwtPlotRenderer renderer;
renderer.exportTo( ui->widget_plot, "shapes.pdf" );
/// Revert plot back to normal (best would be to copy to a new QwtPlot and trash it after this function is done..)
ui->widget_plot->setContentsMargins(0,0,0,0);
}
I would like to copy the QwtPlot with all it's objects (it's just a normal QwtPlot with a few QwtPlotShapeItem)
I have tried to code a copy Constructor, but I'm having problem copying the QwtPlotShapeItem.
Is there an easier solution that I'm missing?
Thanks a lot!
QwtPlotRenderer looks to be perfect for doing this, the only thing is that I need to edit a few thing on the Plot before rendering it.
Right now I just modify the original plot directly before rendering it, which cause the interface to also be modified.
Here is an example :
void WorkoutCreator::exportWorkoutToPdf() {
/// TODO: Add Title, remove background image, increase margins
ui->widget_plot->setContentsMargins(20,20,20,20);
QwtPlotRenderer renderer;
renderer.exportTo( ui->widget_plot, "shapes.pdf" );
/// Revert plot back to normal (best would be to copy to a new QwtPlot and trash it after this function is done..)
ui->widget_plot->setContentsMargins(0,0,0,0);
}
I would like to copy the QwtPlot with all it's objects (it's just a normal QwtPlot with a few QwtPlotShapeItem)
I have tried to code a copy Constructor, but I'm having problem copying the QwtPlotShapeItem.
Is there an easier solution that I'm missing?
Thanks a lot!