Hi,
I was trying to use qwt's plot marker like the code below and I am expecting it to show up everytime i am done selecting with my picker.
#include <qwt_plot.h>
#include <qwt_plot_picker.h>
#include <qwt_plot_marker.h>
//definition
{
Q_OBJECT
public:
virtual ~MyPlot();
protected:
private:
private slots:
void showMark(const QwtDoubleRect&);
};
#include <qwt_plot.h>
#include <qwt_plot_picker.h>
#include <qwt_plot_marker.h>
//definition
class MyPlot : public QwtPlot
{
Q_OBJECT
public:
MyPlot(QWidget* parent);
virtual ~MyPlot();
protected:
private:
QwtPlotPicker* d_picker;
QwtPlotMarker* d_marker;
private slots:
void showMark(const QwtDoubleRect&);
};
To copy to clipboard, switch view to plain text mode
// implementation
#include "myplot.h"
{
//ctor
this->canvas());
d_picker
->setRubberBandPen
(QColor(Qt
::green));
d_picker
->setRubberBand
(QwtPicker::RectRubberBand);
d_picker
->setTrackerPen
(QColor(Qt
::black));
d_picker
->setSelectionFlags
(QwtPicker::RectSelection);
connect (d_picker,SIGNAL(selected(const QwtDoubleRect&)),
this,SLOT(showMark(const QwtDoubleRect&)));
d_marker->attach(this);
}
MyPlot::~MyPlot()
{
//dtor
}
void MyPlot::showMark(const QwtDoubleRect& rect)
{
d_marker->setValue(rect.topLeft() ) ;
d_marker
->setLabel
(QwtText("I am here"));
d_marker->show();
}
// implementation
#include "myplot.h"
MyPlot::MyPlot(QWidget* parent)
:QwtPlot(parent)
{
//ctor
d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPicker::PointSelection | QwtPicker::DragSelection,
QwtPlotPicker::NoRubberBand, QwtPicker::ActiveOnly,
this->canvas());
d_picker->setRubberBandPen(QColor(Qt::green));
d_picker->setRubberBand(QwtPicker::RectRubberBand);
d_picker->setTrackerPen(QColor(Qt::black));
d_picker->setSelectionFlags(QwtPicker::RectSelection);
connect (d_picker,SIGNAL(selected(const QwtDoubleRect&)),
this,SLOT(showMark(const QwtDoubleRect&)));
d_marker = new QwtPlotMarker();
d_marker->setLineStyle(QwtPlotMarker::NoLine);
d_marker->attach(this);
}
MyPlot::~MyPlot()
{
//dtor
}
void MyPlot::showMark(const QwtDoubleRect& rect)
{
d_marker->setValue(rect.topLeft() ) ;
d_marker->setLabel(QwtText("I am here"));
d_marker->show();
}
To copy to clipboard, switch view to plain text mode
please fix /straigtened me out
baray98
Bookmarks