Results 1 to 4 of 4

Thread: how to create the legends which is having line & symbol?

  1. #1
    Join Date
    Feb 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Windows

    Question how to create the legends which is having line & symbol?

    Hi Friends,

    i wanted to show the legends in such a way that it should show lines with symbols...

    but LegendAttributes doesnot have such option ...it will allow either LegendShowLine or LegendShowSymbol...

    like below:

    "defaultcurve->setLegendAttribute(QwtPlotCurve::LegendShowLine,t rue);
    defaultcurve->setLegendAttribute(QwtPlotCurve::LegendShowSymbol ,true);"

    can anyone please suggest how i can achieve the legends which is having both lines with symbols?

    Thanks & Regards,
    Muthu

  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: how to create the legends which is having line & symbol?

    Quote Originally Posted by mammaiap View Post
    can anyone please suggest how i can achieve the legends which is having both lines with symbols?
    You already posted the correct code.

    Unfortunately the layout/render code for the legend is pretty bad in Qwt 6 and you might have effects like that the line is covered by the symbol.

    Uwe

  3. #3
    Join Date
    Feb 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to create the legends which is having line & symbol?

    Hi Uwe,

    Thanks for your reply...

    but what i can do to achieve this??

    Regards,
    mammaiap

  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: how to create the legends which is having line & symbol?

    Well, the first step is to test your legend with a symbol in XCross style, that doesn't cover all space below its bounding rectangle. If the line is visible now we know that both are really painted.

    One possible solution to solve your problem is to increase the width for the identifier, so you can see the line in the additional space. This can be done somehow this way:

    Qt Code:
    1. class YourCurve: public QwtPlotCurve
    2. {
    3. public:
    4. ...
    5.  
    6. virtual void updateLegend( QwtLegend *legend ) const
    7. {
    8. QwtLegendItem *legendItem =
    9. qobject_cast<QwtLegendItem *>( legend->find( this ) );
    10. if ( legendItem )
    11. {
    12. QSize sz = symbol()->boundingSize();
    13. legendItem->setIdentifierSize(
    14. QSize( 3 * sz.width(), sz.height() ) );
    15. }
    16.  
    17. QwtPlotItem::updateLegend( legend );
    18. }
    19. };
    To copy to clipboard, switch view to plain text mode 
    Uwe

Similar Threads

  1. Replies: 0
    Last Post: 10th May 2011, 14:58
  2. How to display external legends in Qwt?
    By saliemam in forum Newbie
    Replies: 0
    Last Post: 1st December 2010, 03:33
  3. Replies: 1
    Last Post: 22nd June 2010, 19:56
  4. Replies: 1
    Last Post: 25th May 2010, 14:44
  5. Qwt: How to create legends inside plots ?
    By Comer352l in forum Qwt
    Replies: 5
    Last Post: 16th August 2009, 18:02

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.