Results 1 to 4 of 4

Thread: Can I change the text color in my legend to match the curve color?

  1. #1
    Join Date
    Dec 2009
    Location
    New Hampshire, USA
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Can I change the text color in my legend to match the curve color?

    Using Qt 4.6.0 and qwt 5.2.0

    I want the text in my legend to match the color of the curve it represents. Is there a way to do that?

  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: Can I change the text color in my legend to match the curve color?

    The text of the legend is copied from the curve title. If you assign a color to the title (QwtText::setColor) I would expect to see it on the legend as well.

    Uwe

  3. #3
    Join Date
    Dec 2009
    Location
    New Hampshire, USA
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can I change the text color in my legend to match the curve color?

    Yup, that did it, thanks. How about changing the background color of the legend? I've tried setPalette() on the legend, but this didn't have any effect.

  4. #4
    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: Can I change the text color in my legend to match the curve color?

    The legend is a container widget around a scrollview, that contains another containter widget (QwtLegend::contentsWidget()), with the legend item widgets inside.

    If you want to find the legend item widget, that corresponds to a specific plot item ( f.e for assigning the color of the curve to its palette ) you can use QwtLegend::find ( QwtPlotItem is derived from QwtLegendItemManager ). Overloading QwtPlotItem::updateLegend() is the place to do this.

    If you want to have your own type of widget (instead of QwtLegendItem) to be displayed on the legend, implement YourCurve::legendItem() and YourCurve::updateLegend().

    Uwe

    PS: Qwt is open source - why not looking into the code to identify the internal widget trees.

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

    AwareWolf (22nd January 2010)

Similar Threads

  1. change text color on QRadioButton
    By vonCZ in forum Newbie
    Replies: 4
    Last Post: 7th November 2012, 21:05
  2. How to change text color of push button?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 11:32
  3. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 23:25
  4. how to change text color in QTableView?
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2008, 11:03
  5. Change the text color tab page
    By gtthang in forum Qt Programming
    Replies: 4
    Last Post: 18th February 2006, 18:38

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.