diff --git a/fastplot.cpp b/fastplot.cpp index 51e5be02e..52ddf65c1 100644 --- a/fastplot.cpp +++ b/fastplot.cpp @@ -34,6 +34,7 @@ FPlotter::FPlotter(QWidget *parent) : //FPlotter Constructor m_ScalePixmap.fill(Qt::white); drawScale(); draw(); + setMouseTracking(true); } FPlotter::~FPlotter() { } // Destructor @@ -211,6 +212,24 @@ void FPlotter::draw() //draw() update(); //trigger a new paintEvent } +void FPlotter::mouseMoveEvent(QMouseEvent *event) +{ + QPainter painter(&m_HorizPixmap); + int x=event->x(); +// int y=event->y(); + float t=x/m_pixPerSecond; + QString t1; + t1.sprintf("%4.1f",t); + if(m_t1.length()==4) { + painter.setPen(Qt::black); + painter.drawText (380,90,m_t1); + } + painter.setPen(Qt::yellow); + painter.drawText (380,90,t1); + update(); + m_t1=t1; +} + void FPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent { int x=event->x(); diff --git a/fastplot.h b/fastplot.h index 988015b01..e18c4d129 100644 --- a/fastplot.h +++ b/fastplot.h @@ -45,6 +45,7 @@ protected: private slots: void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); private: @@ -57,6 +58,7 @@ private: QString m_HDivText[483]; QString m_t; QString m_t0; + QString m_t1; double m_pixPerSecond;