Hi everyone,
I'm trying to print a QwtPlot, but it is only printed in gray scale. Here is the code:
printer.
setOrientation(QPrinter::Landscape);
printer.
setOutputFormat(QPrinter::NativeFormat);
dialog->setWindowTitle(tr("Print Plot: ") + myPlotName);
if (dialog
->exec
() != QDialog::Accepted) return;
painter.begin(&printer);
painter.setPen( Qt::black);
painter.
setFont(QFont("Arial",
12));
my_plot
->print
(&painter,
QRect(100,
100,
800,
600), filter
);
QString dateLabel
= "Produced on: " + QDate::currentDate().
toString() + " at: " + QTime::currentTime().
toString();
painter.
drawText(QRect(0,
0,
600,
600), dateLabel
);
painter.end();
QPrinter printer;
printer.setOrientation(QPrinter::Landscape);
printer.setOutputFormat(QPrinter::NativeFormat);
printer.setColorMode(QPrinter::Color);
QPrintDialog *dialog = new QPrintDialog(&printer, 0);
dialog->setWindowTitle(tr("Print Plot: ") + myPlotName);
if (dialog->exec() != QDialog::Accepted) return;
QPainter painter;
painter.begin(&printer);
painter.setPen( Qt::black);
painter.setFont(QFont("Arial", 12));
QwtPlotPrintFilter filter;
my_plot->print(&painter, QRect(100,100,800,600), filter);
QString dateLabel = "Produced on: " + QDate::currentDate().toString() + " at: " + QTime::currentTime().toString();
painter.drawText(QRect(0,0, 600, 600), dateLabel);
painter.end();
To copy to clipboard, switch view to plain text mode
The curious thing, if I export it as PDF:
printer.
setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
To copy to clipboard, switch view to plain text mode
It is correctly exported, in color.
Any idea please??
Thanks in advance
Bookmarks