PDA

View Full Version : QwtPlot with patient monitor style



P@u1
5th July 2011, 11:48
Hi everyone,

I'm trying to display plots with QwtPlot in this way:
http://www.youtube.com/watch?v=-K9Aj49hHzA
Note how the curve is "eaten up" and not just moved.

My first approach looks like this:


void QwtTest::timerEvent(QTimerEvent * event)
{
for(int i = 0; i < 5; ++i)
{
yData_[currXPos_] = sin(2*pi*sinPos_/(0.169*dataSize_));
++sinPos_;
currXPos_ = (currXPos_ + 1) % dataSize_;
}
ui.qwtPlot->replot();
//everything until here is working, this makes the curve restart at the left hand side when the right hand side is reached
//now i want to overpaint parts of the plot to get the free space between the 2 parts of the curve
QPainter painter(ui.qwtPlot);
painter.setPen(Qt::blue);
painter.fillRect(ui.qwtPlot->rect(), QColor(0,0,0));
//this part does not do anything...
}


Do you have any suggestions?
Thanks in advance!

d_stranz
7th July 2011, 04:54
You can't use QPainter outside of a paintEvent() handler, so whatever you want to draw on the plot has to be done inside the QwtPlot paintEvent. So, you will probably have to derive from QwtPlot, reimplement drawCanvas() to draw your things after the normal QwtPlot::drawCanvas() is finished.