2

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?

Nicolas Holthaus
  • 7,763
  • 4
  • 42
  • 97
  • Thankfully, PDF is the defacto page description language, and most printers can print PDFs directly without converting them to PS first. Generally speaking, there's little need to emit postscript these days. – Kuba hasn't forgotten Monica Sep 22 '15 at 15:25
  • I generally agree, but it depends on your application. If you're trying to manipulate the file in, say, Adobe Illustrator, it's much easier to work with a *.eps file than a *.pdf (or so I'm told by the people paying me to do this). – Nicolas Holthaus Sep 22 '15 at 15:55
  • 1
    Postscript may be better if you intend to manipulate the result in other ways such as injecting your own code (make rgb -> cmy for example) – joojaa Dec 01 '15 at 03:28

1 Answers1

2

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.

Nicolas Holthaus
  • 7,763
  • 4
  • 42
  • 97