Results 1 to 3 of 3

Thread: Change icon color of legendItem

  1. #1
    Join Date
    Apr 2011
    Location
    Bayreuth, Bayern
    Posts
    24
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Change icon color of legendItem

    Hey!
    I need to manually change the color of the legend item to match the curve's line color, not the curve's background, which is the default. Each MyLegendItem is derived from QwtLegendItem. However I cannot find the right place in the code where I would have to call setBrush() or something similar.

    Any ideas? Thanks in advance!

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

    Default Re: Change icon color of legendItem

    The plot item is responsible for how it is represented on the legend - not the legend item. When the options of QwtPlotCurve::setLegendAttribute() doesn't offer what you need, you have to overload QwtPlotCurve::drawLegendIdentifier().

    Uwe

    PS: Note that the legend system is different for Qwt from SVN trunk

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

    missoni (18th October 2012)

  4. #3
    Join Date
    Apr 2011
    Location
    Bayreuth, Bayern
    Posts
    24
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Change icon color of legendItem

    Thank you very much, Uwe!
    I had to overload MyCurve::drawLegendIdentifier() and replace the default brush with another one (whereas MyCurve:: public QwtPlotIntervalCurve).
    Last edited by missoni; 18th October 2012 at 09:11. Reason: smiley replacement

Similar Threads

  1. How to preserve item's icon color ?
    By AlexSudnik in forum Qt Programming
    Replies: 2
    Last Post: 29th April 2011, 22:58
  2. Can't change toolbutton icon
    By waynew in forum Newbie
    Replies: 4
    Last Post: 8th December 2010, 08:37
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. Change Application Icon
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2008, 07:14
  5. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25

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.