text on QwtPlot
Brought to you by:
rathmann
From: Kamran I. <kam...@gm...> - 2005-03-23 15:52:48
|
Hi I have QwtPlot with a time indexed x-axis What I need is to display the exact time of the rendered curves in the plot while the user moves the cursor inside, that is a text string following the cursor and being upddated. The text is like 2005-082:15.45.36 (year-day_of_year, hour, minutes, seconds, millisecons) What I have done (patching from examples) in the following displays the text but it leaves a trail behind which eventually leaves a messy screen: -------------------------------------------------- class dataPlot: public QwtPlot { public: dataPlot(...) { canvas()->setMouseTracking(TRUE); canvas()->installEventFilter(this); } virtual bool eventFilter(QObject *object, QEvent *e) { if ( object != (QObject *)this->canvas() ) return FALSE; switch(e->type()) { case QEvent::MouseButtonPress: { .... } case QEvent::MouseButtonRelease: { .... } case QEvent::MouseMove: { x = ((QMouseEvent *)e)->x(); y = ((QMouseEvent *)e)->y(); xposition = this->invTransform(this->xBottom, x); yposition = this->invTransform(this->yLeft, y); millisecs = int((xposition - double((int)xposition))*1000); dt = dt.addSecs((int)xposition); d = dt.date(); t = dt.time(); ds.sprintf("%d-%03d:%02d.%02d.%02d.%03d",d.year(),d.dayOfYear(), t.hour(),t.minute(),t.second(),millisecs); p.setClipping(TRUE); p.setRasterOp(XorROP); p_pen.setColor(QColor((bg.rgb() ^ pen.color().rgb()))); p.setPen(p_pen); p.drawText(x, y, ds); dt = dt.addSecs((int)(-1.0*xposition)); } default: break; } return QwtPlot::eventFilter(object, e); } --------------------------------- what am I doing wrong ? Thanks in advance Kamran |