//绘制竖直方向的直线
for(int t=0;t<this->width();t++)
{
if(t%50==0)
{
painter.drawLine(t,0,t,-this->height());
}
}
} void Drawer::drawCurves(QPainter &painter)//绘制实时曲线 { painter.setPen(Qt::black); displayDatafypos=displayDatacharge; displayDatacharge=displayDatalypos; painter.drawLine(this->width()+this->pixel,-displayDatafypos,this->width(),-displayDatalypos); } void Drawer::paintEvent(QPaintEvent *) { QPainter paint(this); paint.setBrush(Qt::white);//设置绘制背景的笔的颜色 paint.setViewport(0,0,this->width(),this->height());//设置视口,物理坐标 paint.setWindow(QRect(0,-this->height(),this->width(),this->height()));//设置窗口,逻辑坐标 paint.drawRect(0,-this->height(),this->width(),this->height());//绘制背景 if(Close!=true) { drawGrid(paint); drawCurves(paint); } } void Drawer::timerEvent(QTimerEvent *event) //当时钟周期定义是启动 { int testpos ; if(event->timerId()==myTimerId){ scroll(this->pixel,0); testpos = *pPosition; testpos = testpos/8388608/2; testpos = testpos +150; displayDatalypos=testpos; //数据的入口; // displayDatalypos=rand()%150; //数据的入口;