for(int i=0;i<200;i++){
buffer1=(int)(sin((i*PI)/100)*50); }
QTimer *timer1 = new QTimer(this);
connect(timer1,SIGNAL(timeout()),this,SLOT(flushBuff1()));
timer1->start(50);
for(int j=0;j<101;j++){
buffer2[j]=(int) j; }
for(int j=101;j<200;j++){
buffer2[j]=(int)(200-j); }
QTimer *timer2 = new QTimer(this);
connect(timer2,SIGNAL(timeout()),this,SLOT(flushBuff2()));
timer2->start(50); }
改成
for(int i=0;i<200;i++){
buffer1=(int)(sin((i*PI)/100)*50); }
timer1 = new QTimer(this); connect(timer1,SIGNAL(timeout()),this,SLOT(flushBuff1()));
timer1->start(50);
for(int j=0;j<101;j++){
buffer2[j]=(int) j; }
for(int j=101;j<200;j++){
buffer2[j]=(int)(200-j); }
timer2 = new QTimer(this); connect(timer2,SIGNAL(timeout()),this,SLOT(flushBuff2()));
timer2->start(50); }
然后在头文件中声明
QTimer *timer2;
QTimer *timer1;