PDA

View Full Version : QwtPlot Brush and PDF output



giusepped
21st January 2009, 08:31
I have set the brush as in this code


plotEnergy = new QwtPlotCurve();
plotEnergy->attach(this);
plotEnergy->setPen(QPen(Qt::red));
plotEnergy->setBrush(QBrush(Qt::Dense7Pattern));


But when export the pdf I get the picture attached.
The export is done as simple as:


QString fileName;
fileName = QFileDialog::getSaveFileName(this, tr("Nome file da esportare"), QDir::homePath(),"Acrobat ( *pdf)");

if ( !fileName.isEmpty() ) {
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(fileName);
printer.setCreator("Solar Calc");
printer.setOrientation(QPrinter::Landscape);




QwtPlotPrintFilter filter;
// if ( printer.colorMode() == QPrinter::GrayScale )

int options = QwtPlotPrintFilter::PrintAll;
options &= ~QwtPlotPrintFilter::PrintBackground;
options |= QwtPlotPrintFilter::PrintFrameWithScales;
filter.setOptions(options);


print(printer,filter);

Uwe
21st January 2009, 18:41
When you zoom in you will see, that the pattern is in your PDF document. Obviously this is the result when painting such a pattern to a paint device with a high resolution. This is done by Qt and I'm afraid there is nothing Qwt can do - at least I'm not aware of a workaround.

The pattern should be o.k. when you print to a QPrinter with a similar resolution as on screen, but you also lose the precision for mapping the curve points to the document. As soon as Qwt is able to render to doubles the resolution of the QPrinter will be unimportant for scalable document formats like SVG/PDF.

Uwe