我现在是想在屏幕的(0,0,250,200)矩形区域不停的绘图,而在这个矩形外面的其它区域在需要的时候(例如有一个特定变量改变了)才被重新绘制,我试了用一个定时器来定时的调update(0,0,320,240),而绘图函数都在paintEvent( QPaintEvent *event ),程序如下:
refreshScrTimer = new QTimer( this, "refreshScrTimer");
connect(refreshScrTimer, SIGNAL( timeout() ),this, SLOT( FlushBuf ( ) ) );
refreshScrTimer->start(25);
void abcWidget::FlushBuf( )
{
if(updateFlag==true) update( 0, 0, 320, 240 );
else update( 0, 0, 250, 200 );
}
void abcWidget::paintEvent( QPaintEvent *event )
{
//画(0,0,250,200)矩形区域的代码
//.......................
//画其他区域的代码
if(updateFlag==true)
{
QPainter painter1(otherDispFrm);
DrawOtherDispFrm(&painter1);
updateFlag=false;
}
}
现在出现的问题是如果按照上面的程序其他区域没有显示出来(只画了一次),我希望花一次它后它就显示出来,而当updateFlag被置为true时重绘它,请问如何解决?谢谢!
[ 此贴被gavinyan在2008-04-16 18:57重新编辑 ]