View Full Version : A crosshair which tracks a displayed curve

17th January 2008, 18:16
I need to implement the following functionality and am having trouble getting

With a qwtplot having focus hitting a 'c' on the keyboard will cause a red cross
hair to appear in the graph. Using the mouse or the arrow keys will cause the
intersection point of the red crosshairs to follow the displayed curve.

I can get the red crosshair to appear when I click in the plot, but it disappears
as soon as I release the mouse.

Having the crosshair follow the curve - I have no idea...

Can someone point me in the right direction?


17th January 2008, 20:24
Can we see some code?

17th January 2008, 20:40
The only code I have is a hacked up version of the Bode plot..

The images I attached are of a different app which I need to emulate.


d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,

will give me the Cross hair when I left click.

I want this to persist when I release the mouse and then be able to grab it and
move it with it following the displayed curve..

17th January 2008, 21:28
Shouldn't you use QwtPlotMarker instead?

18th January 2008, 07:16
All type of rubberbands support interactions, but they are not intended to display something persistant on the plot canvas.

So you need to insert a plot item, when your interaction is done. Of course you have to hide this item again, when you restart your interaction. So your code will be a combination of a picker and a plot item.

The plot item, that represents a point ( or a x or a y coordinate ) is indeed a marker, but you can also implement your own type of item. See f.e: http://qwt.svn.sourceforge.net/viewvc/qwt/trunk/qwt/examples/navigation/plot.cpp?view=markup


20th January 2008, 21:47
Hi Uwe,

I wanted to look at the Navigation example but realize that it references some
files that are not part of my qwt version. QwtPlotRescaler for example.

It appears that these files, QwtPlotRescaler.cpp, .h have been around for a while, yet they are not part of my qwt-5.0.2 build.

Why are these files not part of my qwt system and what do I need to do to build the
Navigation example?

Many thanks.


22nd January 2008, 07:32
Why are these files not part of my qwt system and what do I need to do to build the
See http://qwt.sourceforge.net