Results 1 to 3 of 3

Thread: Using QwtlegendData to Display a new column in the legend

  1. #1
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Using QwtlegendData to Display a new column in the legend

    Hi, I'm planning to add a plotPicker to my plot, and when the user selects a position on the plot I want to display the x and y values of a curve in its legend entry based on the plotPicker (basically I want to implement a cursor feature and display the values in the plotLegend).

    I'm planning to overload QwtPlotItem::legendData() to return the 2 new attributes to the legend from my plotCurves, but I'm not sure what I need to change in the legend once I have these two new attributes that lets me define how they'll be displayed once they've been received by legendData(). I was hoping to put them in something like a QLabel with a border to distinguish these entries from the icon and title legend data attributes if at all possible.

    If this isn't possible let me know if there's some other sort of separator I can use in the legend as I don't want to have something plain like just appending these values to the curve's title unless it's my only option.

    Thanks,
    TEAmerc

  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: Using QwtlegendData to Display a new column in the legend

    Well, in general you can overload QwtAbstractLegend::updateLegend() to do whatever you want with these additional attributes. You could even implement your own style of legend, like it is done in the stockchart example.
    But why not setting up a signal/slot connection between picker and legend - sounds more logical to me than passing those attributes as legend data ?

    Uwe

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

    TEAmerc (25th November 2015)

  4. #3
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using QwtlegendData to Display a new column in the legend

    That would work too, I was originally thinking about setting up the signal/slot connection between the picker and the curve and letting the curve pass the information to the legend (I've already subclassed the QwtPlotCurve for other things so it would be a small change), but I'll have to subclass QwtAbstractLegend either way I guess so it won't really save me work. Also, with your way I won't have to call updateLegend every time to update it so I'll do it that way and look into making a custom legend like in the stockchart example.

    Thanks,
    TEAmerc

Similar Threads

  1. Replies: 1
    Last Post: 20th November 2015, 09:12
  2. Replies: 3
    Last Post: 17th December 2014, 09:55
  3. detecting the width of column needed to display data
    By mentalmushroom in forum Qt Programming
    Replies: 0
    Last Post: 17th March 2011, 15:43
  4. Changing QTableView column display order
    By scarleton in forum Qt Programming
    Replies: 3
    Last Post: 18th October 2010, 00:04
  5. Display value in tableWidget row/column
    By sosanjay in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2009, 08:04

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.