Results 1 to 3 of 3

Thread: Having a little trouble printing QwtPlot v6.0.2 in portrait mode

  1. #1
    Join Date
    Dec 2008
    Location
    California, USA
    Posts
    18
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Having a little trouble printing QwtPlot v6.0.2 in portrait mode

    Uwe, I'm finishing up Qwt 5.2.0 to Qwt 6.0.2 porting. Everything is looking good so far except that I can't figure out how to print a color portrait QwtChart to portrait paper. Printing in landscape is working fine, but when in try to print in portrait, the bottom of the page is always empty. The Image appears to be compressed into the top half of the portrait print.

    Let me try to explain what I'm doing. First I do ...

    printer.setOrientation(QPrinter::Portrait);
    printer.setPageSize(QPrinter::Letter);

    and pop up the QprintDialog

    Then after the user accepts the dialog, In Qwt 5.2.0, I used to use:

    QwtPlotPrintFilter filter;
    if ( printer.colorMode() == QPrinter::GrayScale ) {
    filter.setOptions(QwtPlotPrintFilter::PrintAll
    & ~QwtPlotPrintFilter::PrintBackground);
    }
    QPainter painter(&printer);
    QRect rect = painter.viewport();
    m_plot->print(&painter, rect, filter);

    Now, with Qwt 6.0.2 I'm using:

    QwtPlotRenderer renderer;
    if ( printer.colorMode() == QPrinter::GrayScale )
    {
    renderer.setDiscardFlag( QwtPlotRenderer:iscardCanvasBackground );
    renderer.setLayoutFlag( QwtPlotRenderer::FrameWithScales );
    }

    renderer.renderTo( m_plot, printer );

    I know I'm issing something. Any help is appreciated.

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

    Default Re: Having a little trouble printing QwtPlot v6.0.2 in portrait mode

    Guess all you need to do is:

    Qt Code:
    1. renderer.renderTo( m_plot, (QPaintDevice &)printer );
    To copy to clipboard, switch view to plain text mode 
    Both versions of renderTo are convenience APIs - in the end all methods end in QwtPlotRenderer::render().

    Have a look at the the implementation.

    Uwe

  3. #3
    Join Date
    Dec 2008
    Location
    California, USA
    Posts
    18
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Having a little trouble printing QwtPlot v6.0.2 in portrait mode

    That worked perfectly !!

    Thanks

Similar Threads

  1. Portrait to Landscape
    By raghavendraningoji in forum Newbie
    Replies: 1
    Last Post: 18th August 2011, 12:57
  2. Printing QwtPlot on QPrinter
    By gkarthick5 in forum Qwt
    Replies: 5
    Last Post: 28th June 2011, 12:33
  3. landscape to portrait
    By Kunjal Garach in forum Newbie
    Replies: 3
    Last Post: 16th May 2010, 22:53
  4. Replies: 13
    Last Post: 18th December 2009, 09:43
  5. printing with QwtPlot::print
    By user in forum Qwt
    Replies: 1
    Last Post: 7th March 2008, 07:56

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.