Here is a piece of code which displays 2 graphs at a time Which is called by 2 threads simultaneously.
@
QPainter *Dys_ecgpainter;
QPainter *Dys_Balpainter;
@
in init function i declare those 2 painters
@
{
Dys_ecgpainter= new QPainter;
ansiscopeMainWindow->ui->DysAutonomia_Test_ECG_frame->setAttribute(Qt::WA_PaintOutsidePaintEvent,true);
Dys_ecgpainter->begin((QWidget*)ansiscopeMainWindow->ui->DysAutonomia_Test_ECG_frame);
Dys_ecgpainter->drawRect(0,0,235,80);
Dys_Balpainter = new QPainter;
ansiscopeMainWindow->ui->DysAutonomia_Test_balANS_frame->setAttribute(Qt::WA_PaintOutsidePaintEvent,true);
Dys_Balpainter->begin( (QWidget*)ansiscopeMainWindow->ui->DysAutonomia_Test_balANS_frame);
Dys_Balpainter->drawRect(0,0,235,80);
}
@
Dys_DrawECG function is called from ECG thread which plots ecg on a qframe
@
void Dys_DrawECG(int data)
{
Dys_ecgpainter->drawLine(Dys_ECGgraph.lastplot.X,Dys_ECGgraph.lastplot.Y,Dys_ECGgraph.currentplot.X,Dys_ECGgraph.currentplot.Y);
if(Dys_ECGgraph.currentplot.X >= Dys_ECGgraph.rightbottom.X)
{
Dys_ECGgraph.currentplot.X = 0;
Dys_ecgpainter->fillRect(0,0,235,80,Qt::white);
//qWarning("\nAfter reaching end of frame 200\n");
}
Dys_ECGgraph.lastplot.X=Dys_ECGgraph.currentplot.X;
Dys_ECGgraph.lastplot.Y=Dys_ECGgraph.currentplot.Y;
}
@
Dys_DrawbalANS function is called from BalANS thread which plots balANS on a qframe
@
void Dys_DrawbalANS(POINT *Dys_points)
{
int i;
int firsttime=1;
float x,y;
int Xvalue ,Yvalue ;
int Xpos, Ypos;
int balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY;
balCurrentPlotX = 0;
balCurrentPlotY = 0;
balLastPlotX = 0;
balLastPlotY = 0;
Dys_Balpainter->fillRect(0,0,235,80,Qt::white);
Dys_Balpainter->drawLine(117,0,117,20);
Dys_Balpainter->drawLine(60,0,60,10);
Dys_Balpainter->drawLine(174,0,174,10);
Dys_Balpainter->drawLine(0,40,20,40);
Dys_Balpainter->drawLine(0,20,10,20);
Dys_Balpainter->drawLine(0,60,10,60);
firsttime =1;
for(i = 0; i< 312; i++)
{
if(firsttime)
{
firsttime=0;
// Balpainter->moveTo(Xpos,Ypos); //Pen Position
Dys_Balpainter->drawPoint(balCurrentPlotX,balCurrentPlotX);
}
else
{ Dys_Balpainter->drawLine(balCurrentPlotX, balCurrentPlotY, balLastPlotX, balLastPlotY);
}
balLastPlotX = balCurrentPlotX;
balLastPlotY = balCurrentPlotY;
}
}
@
EDIT: please use @-tags for code highlighting, Gerolf