|
我用qt 写了一个画图程序在x86上可以显示动态图形,但是在arm上就非常卡,就像死机了一样,我的程序如下,/****************************************************************************
** Form implementation generated from reading ui file 'frame.ui'
**
** Created: Thu Mar 25 08:15:53 2010
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#define PI 3.1415926
#include "frame.h"
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a mywidget which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
mywidget::mywidget( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "mywidget" );
resize( 320,240 );
setCaption( tr( "frame" ) );
frame=new QFrame(this);
frame->setBackgroundColor(black);
frame->setGeometry(QRect(40,40,200,150));
close = new QPushButton( this, "close" );
close->setGeometry( QRect( 180, 160, 70, 32 ) );
close->setText( tr( "Close" ) );
connect(close,SIGNAL(clicked()),this,SLOT(close()));
for(int i=0;i<200;i++)
{
buffer[i]=(int)(sin((i*PI)/100)*30);
}
QTimer *timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(flushBuff()));
timer->start(30);
}
/*
* Destroys the object and frees any allocated resources
*/
mywidget::~mywidget()
{
// no need to delete child widgets, Qt does it all for us
}
void mywidget::flushBuff()
{
int tmp=buffer[0];
int i;
for(i=0;i<200;i++)
{
buffer[i]=buffer[i+1];
}
buffer[199]=tmp;
repaint(0,0,200,160,TRUE);
}
void mywidget::paintEvent(QPaintEvent *)
{
QPainter painter(frame);
QPoint beginPoint;
QPoint endPoint;
painter.setPen(Qt::blue);
for(int i=0;i<200;i++)
{
beginPoint.setX(2*i);
beginPoint.setY(buffer[i]+50);
endPoint.setX(2*i+1);
endPoint.setY(buffer[i+1]+50);
painter.drawLine(beginPoint,endPoint);
}
}
在x86和arm 上都编译通过了。但是在arm 上运行的时候非常卡,还望高手指点一下,应该怎么解决这个情况。 |
|