PDA

View Full Version : QwtPlotMarker confusion



baray98
18th July 2008, 23:41
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
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&);
};



// 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();
}



please fix /straigtened me out

baray98

Uwe
19th July 2008, 09:49
In PointSelection mode the picker emits a selected(const QwtDoublePoint &) signal (not a rect).

Uwe

baray98
20th July 2008, 05:54
Uwe thanks for the reply but I have modified my instantiation like below but still nothing happen



d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPicker::RectSelection | QwtPicker::CornerToCorner|QwtPicker::DragSelection ,
QwtPlotPicker::VLineRubberBand, QwtPicker::ActiveOnly,
this->canvas());


any more thoughts,

baray98

Uwe
20th July 2008, 10:47
You also forgot to replot ( or enable auto replotting).

Uwe