I created a plot and I would like to print it.
From the Qwt examples, I used the bode example to create a print function:
void plotsMainWindow::print( ResultsPlot * plot )
{
printer.
setOrientation( QPrinter::Landscape );
if ( dialog.exec() )
{
if ( printer.
colorMode() == QPrinter::GrayScale ) {
}
plot->print( printer, filter );
}
}
void plotsMainWindow::print( ResultsPlot * plot )
{
QPrinter printer;
printer.setOrientation( QPrinter::Landscape );
QPrintDialog dialog( &printer );
if ( dialog.exec() )
{
QwtPlotPrintFilter filter;
if ( printer.colorMode() == QPrinter::GrayScale )
{
filter.setOptions ( QwtPlotPrintFilter::PrintAll & ~QwtPlotPrintFilter::PrintCanvasBackground );
}
plot->print( printer, filter );
}
}
To copy to clipboard, switch view to plain text mode
When I try to print to a pdf document, the plot is printed but I have a light gray background.
I would like the plot on a white background, or no background at all.
When defining the canvas for the plot I used:
canvas_
->setBackgroundRole
( QPalette::Window );
canvas_->setAutoFillBackground( true );
canvas_->setBackgroundRole( QPalette::Window );
canvas_->setAutoFillBackground( true );
To copy to clipboard, switch view to plain text mode
the displayed plot on the screen shows a window background but it's different in the printing.
Also the documentation says that QwtPlotPrintFilter will be removed in future versions.
Should I use a different way to print the plot?
Bookmarks