Thanks for ur response @Uwe.
I have tried before the following line as u suggested:
pMyPlotCurve
[channelwidget
]->setItemAttribute
(QwtPlotItem::Legend, ...
);
pMyPlotCurve[channelwidget]->setItemAttribute(QwtPlotItem::Legend, ...);
To copy to clipboard, switch view to plain text mode
But I am not able to control the visibility of legend items as intended.
So far I have written the following lines in a seperate class:
T_INT k;
mPlotCanvas
->setPaintAttribute
(QwtPlotCanvas::BackingStore,
false);
/*-------legend------*/
legend
->setFrameStyle
(QFrame::Box|QFrame
::Sunken);
insertLegend
(legend,
QwtPlot::TopLegend);
/*-------grid------*/
grid->enableXMin(true);
grid
->setMajorPen
(QPen(Qt
::gray,
0, Qt
::DotLine));
grid
->setMinorPen
(QPen(Qt
::gray,
0, Qt
::DotLine));
grid->attach(this);
/*-------curve labels------*/
QVector<QString> vTextLabels;
for (k=0; k< 2; k++)
{
vTextLabels.
append(QString("Signal %1").
arg(k
));
}
QVector <QwtPlotCurve
*> pMyPlotCurve;
for (k=0; k< 2; k++)
{
if (k < vTextLabels.count())
{
}
pMyPlotCurve[k]->attach(this);
}
/*-------curve styles------*/
QVector<QPen> vColor;
vColor.
append(QPen(Qt
::red));
vColor.
append(QPen(Qt
::blue));
for (k=0; k< 2; k++)
{
pMyPlotCurve[k]->setPen(vColor[k%vColor.count()]);
}
T_INT k;
mPlotCanvas = new QwtPlotCanvas;
mPlotCanvas->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
/*-------legend------*/
QwtLegend *legend = new QwtLegend;
legend->setFrameStyle(QFrame::Box|QFrame::Sunken);
insertLegend(legend, QwtPlot::TopLegend);
/*-------grid------*/
QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
grid->setMinorPen(QPen(Qt::gray, 0, Qt::DotLine));
grid->attach(this);
/*-------curve labels------*/
QVector<QString> vTextLabels;
for (k=0; k< 2; k++)
{
vTextLabels.append(QString("Signal %1").arg(k));
}
QVector <QwtPlotCurve*> pMyPlotCurve;
for (k=0; k< 2; k++)
{
if (k < vTextLabels.count())
{
pPlotCurveTime.append(new QwtPlotCurve(vTextLabels[k]));
}
pMyPlotCurve[k]->attach(this);
}
/*-------curve styles------*/
QVector<QPen> vColor;
vColor.append(QPen(Qt::red));
vColor.append(QPen(Qt::blue));
for (k=0; k< 2; k++)
{
pMyPlotCurve[k]->setPen(vColor[k%vColor.count()]);
}
To copy to clipboard, switch view to plain text mode
Now, as mentioned in my previous post, I call the plotting curve vector 'pMyPlotCurve' in another class in the slot function of checkbox as:
QVector<QwtPlotCurve*> pMyPlotCurve;
pMyPlotCurve[channelwidget]->setVisible(true); //or false depending on the 'checkbox' toogling of each channel.
QVector<QwtPlotCurve*> pMyPlotCurve;
pMyPlotCurve[channelwidget]->setVisible(true); //or false depending on the 'checkbox' toogling of each channel.
To copy to clipboard, switch view to plain text mode
Currently I have the Im_1.jpg
I would like to achieve Im_2.jpg. The curves which I select to be visible should have their legend items displayed either on left or right.
The layout system of QwtPlot is not able to handle more than one legend, so if you need to have more than one legend you have to implement the layout code yourself. On screen this can be done using the standard Qt layouts easily.
Can u please show me an example, where multiple legend widgets can be displayed using Qt layouts? When I add another legend widget by:
legend1
->setFrameStyle
(QFrame::Box|QFrame
::Sunken);
insertLegend
(legend1,
QwtPlot::TopLegend);
legend2
->setFrameStyle
(QFrame::Box|QFrame
::Sunken);
insertLegend
(legend1,
QwtPlot::RightLegend);
QwtLegend *legend1 = new QwtLegend;
legend1->setFrameStyle(QFrame::Box|QFrame::Sunken);
insertLegend(legend1, QwtPlot::TopLegend);
QwtLegend *legend2 = new QwtLegend;
legend2->setFrameStyle(QFrame::Box|QFrame::Sunken);
insertLegend(legend1, QwtPlot::RightLegend);
To copy to clipboard, switch view to plain text mode
only the last declared widget legend2 is shown in the Qwt plot.
Please advice.
Bookmarks