What you need is something like this ( untested ):
class Overlay: public QwtWidgetOverlay
{
public:
QwtWidgetOverlay( canvas )
{
}
void setPosition( const QPointF& pos )
[
m_pos = pos;
updateOverlay();
}
virtual void drawOverlay
( QPainter *painter
) const {
const QwtPlot* plot
= dynamic_cast<const
QwtPlot*>
( parent
()->parent
() );
painter->setPen( Qt::yellow );
painter->drawLine( pos.x(), 0, pos.x(), height() );
painter->drawLine( 0, pos.y(), 0, width() );
}
}
class Overlay: public QwtWidgetOverlay
{
public:
Overlay( QWidget *canvas ):
QwtWidgetOverlay( canvas )
{
}
void setPosition( const QPointF& pos )
[
m_pos = pos;
updateOverlay();
}
virtual void drawOverlay( QPainter *painter ) const
{
const QwtPlot* plot = dynamic_cast<const QwtPlot*>( parent()->parent() );
const QwtScaleMap xMap = plot->canvasMap( QwtPlot::xBottom );
const QwtScaleMap yMap = plot->canvasMap( QwtPlot::yLeft );
const QPointF pos = QwtScaleMap::transform( xMap, yMap, m_pos );
painter->setPen( Qt::yellow );
painter->drawLine( pos.x(), 0, pos.x(), height() );
painter->drawLine( 0, pos.y(), 0, width() );
}
}
To copy to clipboard, switch view to plain text mode
HTH, Uwe
Bookmarks