Results 1 to 3 of 3

Thread: Inserting two legends in a QwtPlot with different content

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Inserting two legends in a QwtPlot with different content

    Hello!

    I have a QwtPlot which, instead of plotting curves, will show only items from a class derived from QwtPlotMarker. This markers will be categorized by both color (item family) and symbol (item type).

    I need to show two legends in such a graph: one will show the color differentiation and should hide or show its contents when the marker colors are selected in a menu and the other, always fully visible, will show the symbol differentiation. My question is: how to do that?

    Two essential problems are being faced here: one is how to add two QwtPlotLegendItem, one at the side of the other and in the same corner of the graph, if the position of such legends are generic ("TopCorner" instead of a move(QPos()) command). If I add two legends to the same spot one would probably go under the other, which is not what I want.

    The second problem is how to do such a division in the plots. For the color plot, I imagine that adding some empty QwtPlotCurves with the right Pens and titles and showing them when appropriate would do the trick. But how to make this only appear in just one of the legends? And how could I create and configure the symbol legend? (for this I have no idea on how to do it).


    Any help would be appreciated.

    Thanks,

    Momergil
    May the Lord be with you. Always.

  2. #2
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Inserting two legends in a QwtPlot with different content

    No one have a clue? I'm quite in a hurry with this

    Btw, the trick with QwtPlotCurves worked just fine. The problem now is really to create the symbol legend.


    I appreciate any help,

    Momergil
    May the Lord be with you. Always.

  3. #3
    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: Inserting two legends in a QwtPlot with different content

    Two essential problems are being faced here: one is how to add two QwtPlotLegendItem, one at the side of the other and in the same corner of the graph
    Overload QwtPlotLegendItem::geometry() and return what you need.

    The second problem is how to do such a division in the plots.
    Qt Code:
    1. virtual void YourLegendItem::updateLegend( const QwtPlotItem *plotItem,
    2. const QList<QwtLegendData> &data )
    3. {
    4. if ( plotItem->rtti() == ... )
    5. return;
    6.  
    7. QwtPlotLegendItem::updateLegend( plotItem, data );
    8. }
    To copy to clipboard, switch view to plain text mode 

    And how could I create and configure the symbol legend?
    The plot items are responsible for the information, that is displayed on the legend. Usually it is the title of the item and the icon, that is returned from QwtPlotItem::legendIcon(). But it is also possible to return more information - what is f.e. used by QwtPlotMultiBarChart.

    All relevant plot items should offer an implementation of QwtPlotItem::legendIcon(), but the default setting of the QwtPlotItem::Legend flag depends on the type of plot item. For curves it is on, while f.e. for markers you would have to enable it to see them on the legend.

    Qt Code:
    1. marker->setItemAttribute( QwtPlotItem::Legend, true );
    To copy to clipboard, switch view to plain text mode 
    Uwe

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

    Momergil (26th June 2014)

Similar Threads

  1. Porting Qwt 6.0 legends to Qwt 6.1
    By kubark42 in forum Qwt
    Replies: 0
    Last Post: 3rd August 2013, 15:10
  2. Multiple Legends
    By Pandimensional in forum Qwt
    Replies: 5
    Last Post: 17th August 2012, 08:02
  3. How to display external legends in Qwt?
    By saliemam in forum Qwt
    Replies: 3
    Last Post: 8th December 2010, 05:53
  4. How to display external legends in Qwt?
    By saliemam in forum Newbie
    Replies: 0
    Last Post: 1st December 2010, 03:33
  5. inserting content in database
    By codeman in forum Qt Programming
    Replies: 2
    Last Post: 3rd June 2009, 16:47

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.