locke
29th March 2010, 11:14
Hi everyone,
I'm trying to print a QwtPlot, but it is only printed in gray scale. Here is the code:
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();
The curious thing, if I export it as PDF:
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
It is correctly exported, in color.
Any idea please??
Thanks in advance
I'm trying to print a QwtPlot, but it is only printed in gray scale. Here is the code:
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();
The curious thing, if I export it as PDF:
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(filename);
It is correctly exported, in color.
Any idea please??
Thanks in advance