Results 1 to 2 of 2

Thread: printing with QwtPlot::print

  1. #1
    Join Date
    May 2007
    Location
    Australia
    Posts
    30
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default printing with QwtPlot::print

    I created a plot and I would like to print it.
    From the Qwt examples, I used the bode example to create a print function:

    Qt Code:
    1. void plotsMainWindow::print( ResultsPlot * plot )
    2. {
    3. QPrinter printer;
    4. printer.setOrientation( QPrinter::Landscape );
    5. QPrintDialog dialog( &printer );
    6. if ( dialog.exec() )
    7. {
    8. if ( printer.colorMode() == QPrinter::GrayScale )
    9. {
    10. filter.setOptions ( QwtPlotPrintFilter::PrintAll & ~QwtPlotPrintFilter::PrintCanvasBackground );
    11. }
    12. plot->print( printer, filter );
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    When I try to print to a pdf document, the plot is printed but I have a light gray background.
    I would like the plot on a white background, or no background at all.
    When defining the canvas for the plot I used:
    Qt Code:
    1. canvas_->setBackgroundRole( QPalette::Window );
    2. canvas_->setAutoFillBackground( true );
    To copy to clipboard, switch view to plain text mode 
    the displayed plot on the screen shows a window background but it's different in the printing.

    Also the documentation says that QwtPlotPrintFilter will be removed in future versions.
    Should I use a different way to print the plot?

  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: printing with QwtPlot::print

    Come on, did you ever try to understand the code you have copied ?
    It disables the background for non colored prints. Simply remove the if condition if you want to disable the background for colored prints too.

    In Qwt 6.x there will be no QwtPlotPrintFilter anymore. Filtering fonts and colors was possible in early Qwt releases, because there were only curves and markers. Today there are many other individual plot items, that are not known to QwtPlot.
    But of course the flags controlling the plot won't be removed.

    Uwe

    PD: I fixed several print layout issues last week. It might be worth to download Qwt from the 5.0 SVN branch.

  3. The following user says thank you to Uwe for this useful post:

    user (10th March 2008)

Similar Threads

  1. problem in printing QTableView
    By miguel_mark in forum Qt Programming
    Replies: 2
    Last Post: 6th February 2008, 08:19
  2. Safe checking the QPrinter::PrintState after printing
    By mSergey in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2008, 16:37
  3. Printing problem in windows
    By joseph in forum Qt Programming
    Replies: 6
    Last Post: 12th July 2007, 08:04
  4. Re: Printing in Qt
    By Jimmy2775 in forum Newbie
    Replies: 3
    Last Post: 12th July 2006, 23:00
  5. Replies: 0
    Last Post: 28th June 2006, 20:49

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.