PDA

View Full Version : how can be known a curve is attached?



Alex22
20th December 2015, 20:46
hi
is there any QwtPlotCurve::function to know is a curve attached or not?
for example there are curve1, curve2,...,curve100 and some of these curves are attached. i need if curve20 was attached now it is be detached

ars
20th December 2015, 21:45
Hello,

I didn't find any "QwtPlotCurve::isAttached()" method in the documentation. However, if you want to check if a curve is attached to a specific QwtPlot, you can get the list of all attached QwtPlotItems by calling QwtPlot::intemList() (or more specifically: QwtPlotDict::itemList(). Note that QwtPlot is derived from QwtPlotDict). Then check if your curve is contained in this list.

Best regards
ars

ars
21st December 2015, 06:38
Hello,

here's an update to my previous post (didn't rember it yesterday). From Qwt documentation of QwtPlotItem:

QwtPlot * plot () const
Return attached plot.
So simply check if curve->plot() is null or not.

Best regards
ars

BulSV
9th July 2016, 12:23
Use signal void QwtPlot::itemAttached (QwtPlotItem *plotItem, bool on) and reimplement for each curve int QwtPlotCurve::rtti () const with Rtti_PlotUserItem + 1, + 2 ... + 100

class MyCurve : public QwtPlotCurve
{
public:
MyCurve(QwtPlotItem::RttiValues value)
{
m_value = value;
}
virtual int rtti () const
{
return m_value;
}
private:
QwtPlotItem::RttiValues m_value;
};