Results 1 to 6 of 6

Thread: Is it possible to get a legend ID using QwtLegend?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is it possible to get a legend ID using QwtLegend?

    Hey,

    The legend item list is sorted, but the key is not the text but the pointer to the widget:
    Qt Code:
    1. "Curve 5" QwtLegendItem(0x931ead0)
    2. "Curve 0" QwtLegendItem(0x931eb48)
    3. "Curve 4" QwtLegendItem(0x931ebe8)
    4. "Curve 1" QwtLegendItem(0x931ec10)
    5. "Curve 6" QwtLegendItem(0x931ecb0)
    6. "Curve 3" QwtLegendItem(0x931ef08)
    7. "Curve 2" QwtLegendItem(0x933ad50)
    8. "Curve 7" QwtLegendItem(0x933ae90)
    9. "Curve 8" QwtLegendItem(0x933af30)
    10. "Curve 9" QwtLegendItem(0x933afd0)
    To copy to clipboard, switch view to plain text mode 

    So answer to question 2 is: list doesn't change the order, it's just ordered by something else that you'd expect.

    I don't know where you got the 'ser_no', but I couldn't find it anywhere in qwt 6.0.1 source I have.

    To answer your original question:
    Create additional map of your curves in format: QMap< QwtPlotItem*, int >, where pointer is your curve, and int is its ID (may be index in other list you have or anything else that you find useful);
    this way in your setConfig() you can get ID of each curve from the pointer you're getting there.

    Now I have a question:
    Why do you need it for?
    There may be something wrong with your thinking here.

  2. The following user says thank you to Spitfire for this useful post:

    cesroc (8th June 2012)

  3. #2
    Join Date
    Feb 2012
    Location
    Stuttgart / Germany
    Posts
    35
    Thanks
    6
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Is it possible to get a legend ID using QwtLegend?

    Hello,

    I found a way to get the ser_no.

    Qt Code:
    1. ((QwtLegendItem*)legendList[i])->identifier().serialNumber();
    To copy to clipboard, switch view to plain text mode 

    It's working know, I have the ID I need and I can find which legend even if they have the same name.

    Thanks for your help.
    Bye

  4. #3
    Join Date
    Jun 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Is it possible to get a legend ID using QwtLegend?

    I'm sorry to reopen this topic.

    I have the same problem but QwtLegendItem doesn't exist now with Qwt 6.1.2! Now we only have QwtPlotLegendItem.

    This line is not possible :
    Qt Code:
    1. ((QwtLegendItem*)legendList[i])->identifier().serialNumber();
    To copy to clipboard, switch view to plain text mode 

    I just can do this but it's not ok :
    Qt Code:
    1. QwtPlotItem *plotItem = plot_spectre->infoToItem( itemInfo );
    2. nom_courbe = plotItem->title().text();
    To copy to clipboard, switch view to plain text mode 

    What can i do?

    Maybe put the legend with QwtPlotLegendItem but i don't arrive to put on right the legend as :
    Qt Code:
    1. insertLegend(legend, QwtPlot::RightLegend);
    To copy to clipboard, switch view to plain text mode 
    The legend is inside the plot.

Similar Threads

  1. QwtLegend orientation on QwtPlot
    By bday1223 in forum Qwt
    Replies: 1
    Last Post: 27th September 2011, 06:26
  2. QwtPolarMarker and QwtLegend
    By lokida in forum Qwt
    Replies: 4
    Last Post: 29th March 2011, 09:00
  3. QwtLegend size
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 11th May 2010, 09:55
  4. QwtLegend size
    By baray98 in forum Qwt
    Replies: 0
    Last Post: 10th May 2010, 05:26
  5. Set Title for QWTLegend...
    By umulingu in forum Qwt
    Replies: 3
    Last Post: 23rd March 2010, 09:28

Tags for this Thread

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.