Results 1 to 6 of 6

Thread: How to print plot to PDF by paging?

  1. #1
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to print plot to PDF by paging?

    We can print plot to pdf by paging with QPrinter's newpage function. But it seems we have to paint the whole plot as many times as the number of the pages and it takes much time.

    Is there any suggestion ?


    In the code , I use QwtPlot's drawItems function to print.

  2. #2
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to print plot to PDF by paging?

    oh ,it works better to set drawitems‘ param QRectF &。
    drawItems( QPainter *, const QRectF &rect,
    const QwtScaleMap maps[axisCnt] )ï¼›

    But still, plot’s axis would be painted。

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

    Default Re: How to print plot to PDF by paging?

    What exactly do you want to achieve: printing one plot in a huge size distributed over several pages ?

    Uwe

  4. #4
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to print plot to PDF by paging?

    yes, that’s right.

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

    Default Re: How to print plot to PDF by paging?

    In the end all high level APIs of QwtPlotRender end up in calling:

    Qt Code:
    1. QwtPlotRenderer::render( QwtPlot *plot, QPainter *painter, const QRectF &plotRect )
    To copy to clipboard, switch view to plain text mode 
    For your use case I would calculate a huge plot size - depending on the number of pages and the size of the plot area on a single page.
    For printing a tile of the plot into an area on the current page all you need to do is to adjust top-left of plotRect and setting up a clip rectangle ( QPainter::setClipRect() ) for the tile before calling QwtPlotRenderer::render.

    The disadvantage of this method is of course that QwtPlotRenderer::render has to be called several times - once for each page. If this is really a performance issue I would try to identify and avoid performance issues in QwtPlotRenderer::render itself first - before trying to avoid several calls.

    Uwe

  6. #6
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: How to print plot to PDF by paging?

    thanks for your advice, I‘ll try it。

Similar Threads

  1. Paging when Printing from QWebView into QPrinter
    By criskross in forum Qt Programming
    Replies: 2
    Last Post: 16th April 2015, 18:54
  2. Replies: 0
    Last Post: 21st April 2014, 03:23
  3. PRint plot with Legend
    By OverTheOCean in forum Qwt
    Replies: 1
    Last Post: 27th July 2011, 09:09
  4. Replies: 0
    Last Post: 9th December 2009, 09:34
  5. Paging a QTableView
    By Jimmy2775 in forum Qt Programming
    Replies: 3
    Last Post: 6th November 2006, 18:54

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.