I'm trying to use QwtPlotRenderer
to save an image of a QwtPlot
as a postscript file. This appears supported in the documentation, however whenever I render with the ".ps" extension, nothing happens.
After some research, it appears that Qt5 removed postscript support from QPrinter
. Does this mean that Qwt 6.1.2 can't render as a postscript when using Qt 5?
Unfortunately, yes, it does.
If we take a look into the qwt_plot_renderer.cpp
source code, we can see that postscript support doesn't extend to Qt version 5 and higher, almost certainly because it's built on the QPrinter::PostScriptFormat
, which has been removed from Qt.
// Excerpt from qwt_plot_renderer.cpp (ln 257)
else if ( fmt == "ps" )
{
#if QT_VERSION < 0x050000
#ifndef QT_NO_PRINTER
QPrinter printer;
printer.setOutputFormat( QPrinter::PostScriptFormat );
printer.setColorMode( QPrinter::Color );
printer.setFullPage( true );
printer.setPaperSize( sizeMM, QPrinter::Millimeter );
printer.setDocName( title );
printer.setOutputFileName( fileName );
printer.setResolution( resolution );
QPainter painter( &printer );
render( plot, &painter, documentRect );
#endif
#endif
}
That said, Qwt does support a variety of portable formats with Qt 5, including PDF and SVG, which are both vector graphics, and one of which is probably suitable for most applications.