Results 1 to 9 of 9

Thread: Qwt Bode example prints always the curves (and its legend lines) in black

  1. #1
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

    Qt Code:
    1. #if 1
    2. QPrinter printer;
    3. #else
    4. QPrinter printer(QPrinter::HighResolution);
    5. #if QT_VERSION < 0x040000
    6. printer.setOutputToFile(true);
    7. printer.setOutputFileName("/tmp/bode.ps");
    8. printer.setColorMode(QPrinter::Color);
    9. #else
    10. printer.setOutputFileName("/tmp/bode.pdf");
    11. #endif
    12. #endif
    13.  
    14. QString docName = d_plot->title().text();
    15. if ( !docName.isEmpty() )
    16. {
    17. docName.replace (QRegExp (QString::fromLatin1 ("\n")), tr (" -- "));
    18. printer.setDocName (docName);
    19. }
    20.  
    21. printer.setCreator("Bode example");
    22. printer.setOrientation(QPrinter::Landscape);
    23.  
    24. #if QT_VERSION >= 0x040000
    25. QPrintDialog dialog(&printer);
    26. if ( dialog.exec() )
    27. {
    28. #else
    29. if (printer.setup())
    30. {
    31. #endif
    32. if ( printer.colorMode() == QPrinter::GrayScale )
    33. {
    34. int options = QwtPlotPrintFilter::PrintAll;
    35. options &= ~QwtPlotPrintFilter::PrintBackground;
    36. options |= QwtPlotPrintFilter::PrintFrameWithScales;
    37. filter.setOptions(options);
    38. }
    39. d_plot->print(printer, filter);
    40. }
    To copy to clipboard, switch view to plain text mode 

    Thanks!
    Last edited by locke; 12th August 2010 at 16:11.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default 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)
    Attached Images Attached Images

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  5. #5
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qwt Bode example prints always the curves (and its legend lines) in black

    Ok, but what about my question ?

    Uwe

  7. #7
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  8. #8
    Join Date
    Jun 2011
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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)

  9. #9
    Join Date
    Jun 2011
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default 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:
    Qt Code:
    1. d_curve1->setPen(QPen(Qt::yellow));
    To copy to clipboard, switch view to plain text mode 
    change it to:
    Qt Code:
    1. d_curve1->setPen(QPen(Qt::yellow, 2, Qt::DashLine));
    To copy to clipboard, switch view to plain text mode 

    Edit Line 76 of plot.ccp:
    Qt Code:
    1. d_curve2->setPen(QPen(Qt::cyan));
    To copy to clipboard, switch view to plain text mode 
    change it to:
    Qt Code:
    1. d_curve2->setPen(QPen(Qt::cyan, 2, Qt::DashLine));
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. QPen pen;
    2. QVector<qreal> dashes;
    3. qreal space = 4;
    4. dashes <<100 << space << 100; //or however you want
    5. pen.setDashPattern(dashes);
    To copy to clipboard, switch view to plain text mode 

    and replace Qt:ashLine with Qt::CustomDashLine in those two lines...
    Last edited by CroOm; 29th July 2011 at 15:01.

Similar Threads

  1. Replies: 1
    Last Post: 12th August 2010, 15:19
  2. Replies: 3
    Last Post: 20th April 2010, 16:49
  3. Replies: 1
    Last Post: 19th March 2010, 13:36
  4. QGLWidget renders black
    By jonasbalmer in forum General Programming
    Replies: 2
    Last Post: 24th January 2010, 15:32
  5. Drag and drop and black background
    By zerobala in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2008, 20:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.