谢谢浪漫天使!我回去把你给的程序看一下!,现在我在把程序进行编译以便放到arm的板子上运行时出了个小问题,希望各位帮忙一下!还是以上次的程序说明一下这个新出的问题
在使用电脑上的g++链接make时没有错误,但我需要把程序载到板子上运行,我就把makefile里的链接改为arm-linux-g++,路径没问题,但是这次make时就出现了:“make****[forever.o] 浮点数例外”的问题,始终编译通不过,而且我cpp文件和头文件里都没有浮点型的数啊,都是整型的,程序如下:
#ifndef FOREVER_H
#define FOREVER_H
#include <qwidget.h>
const int numColors = 120;
class Forever : public QWidget
{
Q_OBJECT
public:
Forever( QWidget *parent=0, const char *name=0 );
protected:
void paintEvent( QPaintEvent * );
void timerEvent( QTimerEvent * );
private slots:
void updateCaption();
private:
int i;
int rectangles;
QColor colors[numColors];
};
#endif //头文件
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <qtimer.h>
#include <qpainter.h>
#include <qapplication.h>
#include <stdlib.h> // defines rand() function
#include <qpixmap.h>
#include "forever.h"
//
// Forever - a widget that draws rectangles forever.
//
//
// Constructs a Forever widget.
//
Forever::Forever( QWidget *parent, const char *name )
: QWidget( parent, name )
{
rectangles = 0;
startTimer(1000); // run continuous timer ,时间间隔
QTimer * counter = new QTimer( this );
connect( counter, SIGNAL(timeout()),
this, SLOT(updateCaption()) );
counter->start( 1000 );
}
void Forever::updateCaption()
{
QString s;
s.sprintf( "Qt Example - Forever - %d rectangles/second", rectangles ); //同上
rectangles = 0;
setCaption( s );
}
//
// Handles paint events for the Forever widget.
//
void Forever::paintEvent( QPaintEvent * ) //开始画图
{
QString str = QString("%1.bmp").arg(i);
QPixmap image(str);
QPainter paint;
paint.begin(this);
paint.drawPixmap(51,53,image);
paint.end();
}
//
// Handles timer events for the Forever widget.
//
void Forever::timerEvent( QTimerEvent * )
{
for ( i=1; i<4; i++ ) {
repaint( TRUE ); // repaint ,擦拭后重画,这里就使依次显示了,但不知怎么
// 会不停的重复依次显示,
rectangles++;
}
}
//
// Create and display Forever widget.
//
int main( int argc, char **argv )
{
QApplication a( argc, argv ); // create application object
QTimer::singleShot( 10*1000, &a, SLOT(quit()) ); //10秒后关闭
Forever always; // create widget
a.setMainWidget( &always ); // set as main widget
always.setCaption("Qt Example - Forever");
always.show(); // show widget
a.exec(); // run event loop
}