Hi to Everyone,
i want the xy-coordinates too, but i want to save it to an integer or a double to display a Marker with a mouse click.
I had connected the Signal as UWE described and the signal is working. But i did not get the values, which are shown next to the mouse at the QwtPlot. e.g. (22000, 800). I only get from d_picker->trackerPosition() something like (139,81) which seem to be the pixel coordinates of the window.
My Question is:
How can i retrieve or transform the data "behind" the pixel-coordinates {like: (22000, 800) } ?
Or which additional Signal, must i connect to get the data which is displayed next to the mouse pointer?
thanks in advance,
Astronomy
here's my code:
CPlot::CPlot() // constructor
// Crosslines of the mouse - SELECTION
d_picker
->setRubberBandPen
(QColor(Qt
::green));
d_picker
->setRubberBand
(QwtPicker::CrossRubberBand);
connect(d_picker,
SIGNAL(moved
(const QPoint &)),
SLOT(moved
(const QPoint &)));
connect(d_picker, SIGNAL(selected(const QwtPolygon &)), SLOT(selected(const QwtPolygon &)));
// connect(d_picker, SIGNAL(selected(const QwtDoublePoint &)), SLOT(selected(const QwtDoublePoint &)));
...[B] // as Uwe said..[/B]
connect(d_picker, SIGNAL(selected(const QwtDoublePoint & )), SLOT(DrawMarkers()) );
...
CPlot::CPlot() // constructor
// Crosslines of the mouse - SELECTION
d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::PointSelection | QwtPicker::DragSelection,
QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, this->canvas());
d_picker->setRubberBandPen(QColor(Qt::green));
d_picker->setRubberBand(QwtPicker::CrossRubberBand);
connect(d_picker, SIGNAL(moved(const QPoint &)), SLOT(moved(const QPoint &)));
connect(d_picker, SIGNAL(selected(const QwtPolygon &)), SLOT(selected(const QwtPolygon &)));
// connect(d_picker, SIGNAL(selected(const QwtDoublePoint &)), SLOT(selected(const QwtDoublePoint &)));
...[B] // as Uwe said..[/B]
connect(d_picker, SIGNAL(selected(const QwtDoublePoint & )), SLOT(DrawMarkers()) );
...
To copy to clipboard, switch view to plain text mode
// My Signal of my QwtPlot derivation...
void CPlot::DrawMarkers()
{
// Here the Markers for the selection will be placed on the plot..
cSelectionMarker
->setLabel
(QString::fromLatin1("x-Selection"));
cSelectionMarker->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
cSelectionMarker->setLabelOrientation(Qt::Vertical);
cSelectionMarker
->setLinePen
(QPen(Qt
::red,
0, Qt
::DashDotLine));
int Test = 0;
// QwtDoublePoint pos;
pos = d_picker->trackerPosition();
test = pos.rx(); // only for debugging: result was 139, seem to be the coordinates of the Window
test = pos.ry(); // debugging resultwas : 81 seem to be the coordinates of the Window
test = d_picker->yAxis(); // debugging: result was 0, this comes from the constructor as a result of QwtPlot::yLeft
test = d_picker->xAxis(); // debugging: result was 2, this comes from the constructor as a result of QwtPlot::xBottom
//d_picker->trackerText(pos);
cSelectionMarker->setXValue( test ); //Set the Marker at mouseclick, not ok
// cSelectionMarker->setXValue( 23000 ); //hardcoded Test, ok
cSelectionMarker->attach(this);
replot();
}
void CPlot::DrawMarkers()
{
// Here the Markers for the selection will be placed on the plot..
QwtPlotMarker *cSelectionMarker = new QwtPlotMarker();
cSelectionMarker->setLabel(QString::fromLatin1("x-Selection"));
cSelectionMarker->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
cSelectionMarker->setLabelOrientation(Qt::Vertical);
cSelectionMarker->setLineStyle(QwtPlotMarker::VLine);
cSelectionMarker->setLinePen(QPen(Qt::red, 0, Qt::DashDotLine));
int Test = 0;
// QwtDoublePoint pos;
QPoint pos;
pos = d_picker->trackerPosition();
test = pos.rx(); // only for debugging: result was 139, seem to be the coordinates of the Window
test = pos.ry(); // debugging resultwas : 81 seem to be the coordinates of the Window
test = d_picker->yAxis(); // debugging: result was 0, this comes from the constructor as a result of QwtPlot::yLeft
test = d_picker->xAxis(); // debugging: result was 2, this comes from the constructor as a result of QwtPlot::xBottom
//d_picker->trackerText(pos);
cSelectionMarker->setXValue( test ); //Set the Marker at mouseclick, not ok
// cSelectionMarker->setXValue( 23000 ); //hardcoded Test, ok
cSelectionMarker->attach(this);
replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks