Results 1 to 3 of 3

Thread: Legend Checked from start

  1. #1
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Legend Checked from start

    Hello,
    I will continue looking, but I am trying to find a way to start a "checkable" legend to all checked on startup. Basically I want the QtPlotCurves all visible at startup with the check's in the ON state. Then the user can check them off.

    I was hoping for something like legend->setChecked(bool tf), that I could call from implementation, but open to any suggestions... I would like to stay away from default showing none and making the user click them all on, but it is one method...
    Here is the connect statement I am using for after the legend is first checked...
    Qt Code:
    1. connect(this,SIGNAL(legendChecked(QwtPlotItem*,bool)), this, SLOT(handleLegendChecked(QwtPlotItem*, bool)));
    To copy to clipboard, switch view to plain text mode 
    and the slot it calls...
    Qt Code:
    1. void dataPlot::handleLegendChecked(QwtPlotItem* item, bool tf)
    2. {
    3. item->setVisible(tf);
    4. replot();
    5. if(cStart->isVisible()){curvesLoaded.start = true;} else {curvesLoaded.start = false;}
    6. if(cRun->isVisible()){curvesLoaded.run = true;} else {curvesLoaded.run = false;}
    7. if(cCmdwn->isVisible()){curvesLoaded.comedown=true;} else {curvesLoaded.comedown = false;}
    8. qDebug()<<curvesLoaded.start<<curvesLoaded.run<<curvesLoaded.comedown;
    9. }
    To copy to clipboard, switch view to plain text mode 

    Thanks to any who can help!
    AlphaWolfXV

  2. #2
    Join Date
    Sep 2010
    Posts
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Legend Checked from start

    here is how I achieve this:

    Qt Code:
    1. QwtLegendItem* label = (QwtLegendItem*)YourLegend.find(&YourPlotItem);
    2. label->setItemMode(QwtLegend::CheckableItem);
    3. label->setChecked(true);
    To copy to clipboard, switch view to plain text mode 

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

    AlphaWolfXV (10th August 2013)

  4. #3
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Legend Checked from start

    I get this error:


    Qt Code:
    1. error: request for member ‘find’ in ‘legend’, which is of non-class type ‘QwtLegend*’
    To copy to clipboard, switch view to plain text mode 

    I use your command lines like this:
    Qt Code:
    1. QwtLegend *legend = new QwtLegend;
    2. legend->setItemMode( QwtLegend::CheckableItem );
    3. myPlot->insertLegend(legend, QwtPlot::BottomLegend);
    4.  
    5. //main Curve
    6. mainCurve = new QwtPlotCurve("mainCurve");
    7. mainCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    8. mainCurve->setPen(QPen(Qt::black));
    9. mainCurve->setLegendAttribute(QwtPlotCurve::LegendShowLine);
    10. QwtLegendItem* label = (QwtLegendItem*)legend.find(&mainCurve);
    11. label->setChecked(true);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Which QCheckBox has been checked?
    By alexandernst in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 11:09
  2. Delete if row checked
    By wirasto in forum Qt Programming
    Replies: 2
    Last Post: 11th July 2009, 15:16
  3. Two groupbox, if checked one, uncheck other
    By webquinty in forum Qt Programming
    Replies: 4
    Last Post: 14th May 2009, 00:40
  4. Checked item in QTreeWidget?
    By vishal.chauhan in forum Qt Programming
    Replies: 18
    Last Post: 3rd January 2008, 21:18
  5. Which QCheckBox is checked?
    By Craig.Smith in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 15:52

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.