Results 1 to 3 of 3

Thread: QwtLegend items disappear when checked off

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default QwtLegend items disappear when checked off

    I've got a plot with a legend that initially appears ok. However, when I click on an item in the legend to deselect it (uncheck it?) it is not only unchecked, but it disappears from the legend entirely. Furthermore, I never get a signal when an item on the legend is clicked.

    Here is part of my code (I have left out quite a bit of code from this class):
    In the constructor of my class, plot_ is a QwtPlot*:
    Qt Code:
    1. QwtLegend * legend = new QwtLegend();
    2. legend->setItemMode(QwtLegend::CheckableItem);
    3. legend->setWhatsThis("Click on an item to show/hide the plot");
    4. plot_->insertLegend(legend, QwtPlot::RightLegend);
    5. connect(plot_, SIGNAL(legendChecked(QwtPlotItem *, bool)),this,
    6. SLOT(showCurve(QwtPlotItem *, bool)));
    To copy to clipboard, switch view to plain text mode 

    Later on, when I add a new curve (newSpec is a QwtPlotSpectrogram* ):
    Qt Code:
    1. newSpec->setItemAttribute(QwtPlotItem::Legend, true); // add to the clickable legend
    2. newSpec->updateLegend(plot_->legend());
    To copy to clipboard, switch view to plain text mode 

    I assume the two problems (signal not set up correctly, items disappearing) are related but I can't figure out why or how to solve it. Thank you very much!

    Edit: forgot to mention, if this helps, the itemCount() of the legend does change (decreases by 1) when one of the legend items disappears.
    Last edited by steve123; 16th May 2011 at 22:09.

Similar Threads

  1. Replies: 2
    Last Post: 2nd September 2010, 20:52
  2. QwtLegend size
    By baray98 in forum Qwt
    Replies: 0
    Last Post: 10th May 2010, 06:26
  3. items in view would disappear on scrolling
    By sepehr in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2009, 08:20
  4. QTableWidget: set items disappear after new insertion
    By Raccoon29 in forum Qt Programming
    Replies: 6
    Last Post: 16th March 2008, 19:28
  5. Iterate and get Checked QTable items??
    By darpan in forum Newbie
    Replies: 2
    Last Post: 10th May 2006, 19:27

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
  •  
Qt is a trademark of The Qt Company.