Qwt Bode example prints always the curves (and its legend lines) in black
Hey guys,
I'm triying to print a QwtPlot and I cannot print its curves in color. I looked at the Bode example, and in the example is the same. You just open the example, go to print and then print it in yout printer (in color) or print in a pdf file with a pdf printer. It is always the same, the curves, amplitude and phase are both black.
There is a bug in the example?, there is a bug in the QwtPlot module? Has anyone else noticed that?
I post here the printing code from the Bode example
Code:
#if 1
#else
#if QT_VERSION < 0x040000
printer.setOutputToFile(true);
printer.setOutputFileName("/tmp/bode.ps");
#else
printer.setOutputFileName("/tmp/bode.pdf");
#endif
#endif
QString docName
= d_plot
->title
().
text();
if ( !docName.isEmpty() )
{
printer.setDocName (docName);
}
printer.setCreator("Bode example");
printer.
setOrientation(QPrinter::Landscape);
#if QT_VERSION >= 0x040000
if ( dialog.exec() )
{
#else
if (printer.setup())
{
#endif
if ( printer.
colorMode() == QPrinter::GrayScale ) {
filter.setOptions(options);
}
d_plot->print(printer, filter);
}
Thanks!
Re: Qwt Bode example prints always the curves (and its legend lines) in black
Should be a problem on your side - here the example prints in color.
Uwe
1 Attachment(s)
Re: Qwt Bode example prints always the curves (and its legend lines) in black
This is a snapshot made to the pdf (printed with doPdf)
Re: Qwt Bode example prints always the curves (and its legend lines) in black
I remember a bug report I had sent to Trolltech long time ago about a bug in the PDF renderer that looked similar to your screenshot. ( AFAIR I had to insert some dummy code to avoid these problem. ) It was rejected as a problem of the PDF viewer.
I never checked if this was true, but does it still happen with Qwt 5.2.1 and Qt 4.6.3 and a recent version of the acrobat reader ?
Uwe
Re: Qwt Bode example prints always the curves (and its legend lines) in black
The problem is not the PDF or Adobe Reader, If I print the plot in a real printer, the curves are black too. I printed this time to a pdf only to show you what Im talking about.
Re: Qwt Bode example prints always the curves (and its legend lines) in black
Ok, but what about my question ?
Uwe
Re: Qwt Bode example prints always the curves (and its legend lines) in black
I am working ow Qt 4.6.1 and Qwt 5.2.0 . and Adobe Reader 9.3.3. I have no problem to print in PDF. It is ok using a QPainter and a QPrinter. But to print in a real printer, then the curves become black.
Re: Qwt Bode example prints always the curves (and its legend lines) in black
Still actual, seems to be a Qwt problem (checked printing to pdf with other programs - functional)
working with QT4.70, QWT 6.0.0, Windows 7 64Bit (Compiler:MinGW)
Re: Qwt Bode example prints always the curves (and its legend lines) in black
It's all in all a little bit strange. As shown in the pdf-document above, not the whole print is B&W , everything is in color except the amplitude-and phaseline.
so itseems it's not a Qt printer setting (QPrinter::ColorMode).
But you can pass this bug by using the export-function in the example:
1. Export 2 .pdf-document
2. Print the created document
Added after 49 minutes:
Problem solved:
Edit Line 69 of plot.ccp:
Code:
d_curve1
->setPen
(QPen(Qt
::yellow));
change it to:
Code:
d_curve1
->setPen
(QPen(Qt
::yellow,
2, Qt
::DashLine));
Edit Line 76 of plot.ccp:
Code:
d_curve2
->setPen
(QPen(Qt
::cyan));
change it to:
Code:
d_curve2
->setPen
(QPen(Qt
::cyan,
2, Qt
::DashLine));
when short version is used, linetype is set to default value Qt::SolidLine ,
but Qt::SolidLine also changes the color to black (when passed to a printer)
If you don't like a dashline, create your own solid line:
Code:
QVector<qreal> dashes;
qreal space = 4;
dashes <<100 << space << 100; //or however you want
pen.setDashPattern(dashes);
and replace Qt::DashLine with Qt::CustomDashLine in those two lines...