Results 1 to 2 of 2

Thread: Printing plot with many legend items

  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Printing plot with many legend items

    Hi Friends,

    got stuck with Qwt (5.2.1) trying to print a plot nicely on a QPrinter.

    I have a QwtPlot with many curves (about 40 of them). Not regarding the need of so many curves in one canvas, I would like to print out the full canvas with the legend besides it.

    If i try the straight forward way (QwtPlot:: print()), I get the Canvas resized nicely to fit the page, but the Legend is not sized down to fit all Items on the page. Instead, it paints them in normal font size overpainting the pageRect that I pass to the QwtPlot:: print() method.
    Qt Code:
    1. QwtPlot* myPlot;
    2. /* here follows the filling of my plot */
    3.  
    4. QPrinter* printer = new QPrinter(QPrinter::HighResolution);
    5. printer->setPageSize(QPrinter::A4);
    6.  
    7. QPainter painter(printer);
    8. myPlot->print(&painter, printer->pageRect());
    9. painter.end();
    To copy to clipboard, switch view to plain text mode 


    I already tried to modify the QwtLegend::legendItems(), each changing font size, margins etc. Nothing seems to help, the legend on the print looks always the same.
    I would expect the QwtPlot:: print(...) method to paint the whole plot including the legend inside(!) the given rect and (if needed) scale down the legend.

    Anyone with suggestions to get that working?
    Thank you for any help.
    Best regards,
    Viktor

  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 plot with many legend items

    Overload the following methods:

    Qt Code:
    1. virtual void QwtPlot::printLegend( (QPainter *, const QRect &) const;
    2. virtual void printLegendItem(QPainter *, const QWidget *, const QRect &) const;
    To copy to clipboard, switch view to plain text mode 
    Uwe

Similar Threads

  1. Spacing around legend items
    By FilipeMaia in forum Qwt
    Replies: 5
    Last Post: 13th August 2015, 09:15
  2. How to insert a legend in my plot?
    By paperflyer in forum Qwt
    Replies: 1
    Last Post: 7th October 2009, 17:04
  3. Sorting plot legend?
    By StefanK in forum Qwt
    Replies: 2
    Last Post: 5th April 2009, 19:29
  4. Replies: 1
    Last Post: 24th February 2009, 18:35
  5. legend inside qwt plot
    By kaustav98255 in forum Qwt
    Replies: 5
    Last Post: 11th February 2009, 20:39

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.