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...
and the slot it calls...
Code:
void dataPlot
::handleLegendChecked(QwtPlotItem* item,
bool tf
) {
item->setVisible(tf);
replot();
if(cStart->isVisible()){curvesLoaded.start = true;} else {curvesLoaded.start = false;}
if(cRun->isVisible()){curvesLoaded.run = true;} else {curvesLoaded.run = false;}
if(cCmdwn->isVisible()){curvesLoaded.comedown=true;} else {curvesLoaded.comedown = false;}
qDebug()<<curvesLoaded.start<<curvesLoaded.run<<curvesLoaded.comedown;
}
Thanks to any who can help!
AlphaWolfXV
Re: Legend Checked from start
here is how I achieve this:
Code:
label
->setItemMode
(QwtLegend::CheckableItem);
label->setChecked(true);
Re: Legend Checked from start
I get this error:
Code:
error
: request
for member ‘find’ in ‘legend’, which is of non
-class type ‘
QwtLegend*’
I use your command lines like this:
Code:
legend
->setItemMode
( QwtLegend::CheckableItem );
myPlot
->insertLegend
(legend,
QwtPlot::BottomLegend);
//main Curve
mainCurve
->setRenderHint
(QwtPlotItem::RenderAntialiased);
mainCurve
->setPen
(QPen(Qt
::black));
mainCurve
->setLegendAttribute
(QwtPlotCurve::LegendShowLine);
label->setChecked(true);