Results 1 to 4 of 4

Thread: QwtPlotLegendItem and QwtLegendItem

  1. #1
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QwtPlotLegendItem and QwtLegendItem

    What is the difference between QwtPlotLegendItem and QwtLegendItem ???

    In the documents, I found QwtLegendItem but not QwtPlotLegendItem.
    In my Qwt library, I found QwtPlotLegendItem but not QwtLegendItem.
    I have
    #include <qwt_plot_legenditem.h>
    but not
    #include <qwt_legenditem.h>


    I'm trying to use
    qwtLegenditem.setItemmode(..)

    but i can not find it. I am using qwtPlotLegendItem

    Thank you.

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

    Default Re: QwtPlotLegendItem and QwtLegendItem

    QwtPlotLegendItem is a new plot item in SVN trunk that displays a legend on the plot canvas - in opposite to QwtLegend that is a widget aligned to the plot canvas. QwtLegendItem is a class you don't need to know as long as you don't want to modify what happens on a QwtLegend.

    I guess you are looking for QwtLegend::setItemMode ( or QwtLegend::setDefaultItemMode with SVN trunk ).

    Uwe

  3. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotLegendItem and QwtLegendItem

    Yes I am using QwtPoltLegendItem, because i want to display the legend on the plot canvas not aligned with the plot.

    I'm trying to change the mode of the QwtPoltLegendItem , so i can click on it and display the curve related to each item on the legend.
    so is there a way to change the item mode for QwtPoltLegendItem or not ??


    Sorry, one more thing is how can i remove a curve from the legend even though still attached to the plot ?
    Last edited by jesse_mark; 13th November 2012 at 15:40.

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

    Default Re: QwtPlotLegendItem and QwtLegendItem

    I'm trying to change the mode of the QwtPoltLegendItem , so i can click on it and display the curve related to each item on the legend. so is there a way to change the item mode for QwtPoltLegendItem or not ??
    Plot items are no widgets - they can't have a focus and they don't get any mouse or key events.

    You could implement an event filter for the canvas ( or with SVN trunk you can overload its mousePressEvent ) where you handle mouse clicks yourself. The geometries of the legend entries are available.

    Another option is to use an external legend - what means a legend that is not known to the layout system of the plot. Then you can put it on top of the canvas manually using QWidget:.setGeometry(). With Qwt 6.0 you would have to insert the legend as QwtPlot::ExternalLegend, with SVN trunk you have to setup a signal/slot connection instead: see the legends example. But note that you will also have to implement some code to layout the legend, when you want to export/print the plot.

    Sorry, one more thing is how can i remove a curve from the legend even though still attached to the plot ?
    Qt Code:
    1. curve->setItemAttribute( QwtPlotItem::Legend, false );
    To copy to clipboard, switch view to plain text mode 
    Uwe

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

    jesse_mark (15th November 2012)

Similar Threads

  1. Replies: 2
    Last Post: 24th January 2012, 12:52
  2. Replies: 4
    Last Post: 4th March 2011, 08:43

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.