Results 1 to 7 of 7

Thread: qwtlegend

  1. #1
    Join Date
    Mar 2009
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qwtlegend

    Hi,

    i use a QwtPlot with a QwtPlotShapeItem...


    Qt Code:
    1. path.addRect(....);
    2.  
    3. plotShapeItem.setRenderHint(QwtPlotItem::RenderAntialiased, true);
    4. plotShapeItem.setShape(path);
    5. plotShapeItem.setItemAttibute(QwtPlotItem::Legend, true);
    6. plotShapeItem.setLegendMode(QwtPlotShapeItem::LegendShape);
    7. plotShapeItem.setLegendIconSize(QSize(20, 20));
    8. plotShapeItem.setTitle(QString("Winter"));
    9. plotShapeItem.attach(&plot);
    To copy to clipboard, switch view to plain text mode 

    how can i make the legend for plotShapeItem enabled? I dont know how to config the QwtLegend in this case... See here:
    legend.png

    I would need the QwtLegendLabel and call setchecked(true)...ideas?

    Thanks,
    S
    Last edited by Surfman19; 5th August 2015 at 16:10.

  2. #2
    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: qwtlegend

    Have a look at the itemeditor example.

    Uwe

  3. #3
    Join Date
    Mar 2009
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtlegend

    i cannot find the relevant part....which file and line do you mean?

    i only found this part, which looks similar what i do: https://github.com/sikoragmbh/qwt/bl....cpp#L92:#L107
    i dont see QwtLegendLabel calling setchecked in this code...ideas?
    Last edited by Surfman19; 5th August 2015 at 22:20.

  4. #4
    Join Date
    Mar 2009
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtlegend

    sorry for the confusion....
    i have upated the image... as you see Winter is not enabled in the legend, but the QwtPlotShapeItem is visible (as expected)
    i want to enable the QwtLegendLabel for Winter ... therefore i need to get the QwtLegendLabel and call setchecked(true)... ideas?

    legend.png
    Last edited by Surfman19; 6th August 2015 at 11:03.

  5. #5
    Join Date
    Mar 2009
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtlegend

    any idea Uwe?

  6. #6
    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: qwtlegend

    tvplot and cpuplot examples show how to get access the legend label for an item.

    When you are wondering, why there is no more obvious getter ( like in earlier Qwt versions ) have a look at the stockchart example, where the legend is replaced by a tree view. It is like with QAbstractItemModel - this mysterious API is the price 99.9% of the applications have to pay to make 0.1% of the use cases possible.

    Uwe

  7. #7
    Join Date
    Mar 2009
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtlegend

    ah thaks...i fixed it, i didnt see that itemList takes different parameters: http://qwt.sourceforge.net/class_qwt...f2f2f2af871bf3

    Qt Code:
    1. QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotShape );
    2. for ( int i = 0; i < items.size(); i++ )
    3. {
    4. QwtLegendItem *legendItem = qobject_cast<QwtLegendItem *>( legend->find( items[i] ) );
    5. if ( legendItem ) {
    6. legendItem->setChecked( true );
    7. }
    8.  
    9. items[i]->setVisible( true );
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Surfman19; 6th August 2015 at 20:21.

Similar Threads

  1. Replies: 5
    Last Post: 26th June 2015, 16:00
  2. DoubleClick on QwtLegend
    By hassinoss in forum Qwt
    Replies: 2
    Last Post: 11th February 2014, 18:37
  3. Qwt 6.1.0 trunk and QwtLegend
    By carhun in forum Qwt
    Replies: 0
    Last Post: 22nd August 2012, 10:13
  4. QwtPolarMarker and QwtLegend
    By lokida in forum Qwt
    Replies: 4
    Last Post: 29th March 2011, 10:00
  5. QwtLegend size
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 11th May 2010, 10:55

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.