Results 1 to 5 of 5

Thread: QwtPolarMarker and QwtLegend

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

    Default QwtPolarMarker and QwtLegend

    Hi,

    I use a QwtPolarMarker but it does not appear in the legend. I have looked at the documentation but have found nothing about this. Try to use legend->insert but dont'know which widget I should pass to this method.

    Any help would be welcome.

    Thank you.

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

    Default Re: QwtPolarMarker and QwtLegend

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

  3. #3
    Join Date
    Mar 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPolarMarker and QwtLegend

    Thank you.
    And note for myself, read completely the documentation...

    So, I have the marker in the legend but the associated symbol is not displayed in the legend.
    Probably an other option that I haven't read in the documentation or is ti normal ?

    Thanks.

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

    Default Re: QwtPolarMarker and QwtLegend

    The default representation of a plot item on the legend is its title and QwtPolarMarker has no special implementation - probably it should have one.

    With Qwt 5.x and QwtPolar 1.0 you have to implement something like this:

    Qt Code:
    1. virtual void YourMarker::updateLegend(QwtLegend *legend) const
    2. {
    3. QwtPolarMarker::updateLegend( legend );
    4. QwtLegendItem *label =
    5. dynamic_cast<QwtLegendItem *>( legend->find(this) );
    6. if ( label )
    7. {
    8. label->setSymbol( symbol() );
    9. label->setIdentifierMode(
    10. QwtLegendItem::ShowSymbol | QwtLegendItem::ShowText );
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    With Qwt 6.x + QwtPolar from SVN trunk you have to implement something like this:

    Qt Code:
    1. virtual void YourMarker::drawLegendIdentifier(
    2. QPainter *painter, const QRectF &rect ) const
    3. {
    4. QSize symbolSize = symbol()->boundingSize();
    5. symbolSize -= QSize( 2, 2 );
    6.  
    7. // scale the symbol size down if it doesn't fit into rect.
    8.  
    9. double xRatio = 1.0;
    10. if ( rect.width() < symbolSize.width() )
    11. xRatio = rect.width() / symbolSize.width();
    12.  
    13. double yRatio = 1.0;
    14. if ( rect.height() < symbolSize.height() )
    15. yRatio = rect.height() / symbolSize.height();
    16.  
    17. const double ratio = qMin( xRatio, yRatio );
    18.  
    19. painter->save();
    20. painter->scale( ratio, ratio );
    21.  
    22. symbol()->drawSymbol( painter, rect.center() / ratio );
    23.  
    24. painter->restore();
    25. }
    To copy to clipboard, switch view to plain text mode 

    Uwe

  5. #5
    Join Date
    Mar 2011
    Posts
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPolarMarker and QwtLegend

    Hi,

    That perfectly works !

    Thank you.

Similar Threads

  1. QwtLegend background in a Tab Widget
    By AnnaP in forum Qwt
    Replies: 1
    Last Post: 7th February 2011, 12:21
  2. QwtLegend size
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 11th May 2010, 09:55
  3. QwtLegend size
    By baray98 in forum Qwt
    Replies: 0
    Last Post: 10th May 2010, 05:26
  4. Adding tooltip for each QwtLegendİtem
    By umituzun84 in forum Qwt
    Replies: 1
    Last Post: 25th March 2010, 07:24
  5. Set Title for QWTLegend...
    By umulingu in forum Qwt
    Replies: 3
    Last Post: 23rd March 2010, 09:28

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.