• 5694阅读
  • 1回复

qt make时奇怪的错误!请教 [复制链接]

上一主题 下一主题
离线dier1983813
 

只看楼主 倒序阅读 楼主  发表于: 2009-02-23
我写了个qt程序,在使用电脑上的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
}
离线guoyun_he

只看该作者 1楼 发表于: 2009-02-24
光改了给你一个我的Makefile作为参考:
CC    =    arm-linux-gcc
CXX    =    arm-linux-g++
CFLAGS    =    -pipe -Wall -W -O2 -DNO_DEBUG
CXXFLAGS=    -pipe -DQWS -fno-exceptions -fno-rtti -DQT_QWS_CUSTOM -Wall -W -O2 -DNO_DEBUG -DQT_THREAD_SUPPORT
INCPATH    =    -I$(QTDIR)/include
LINK    =    arm-linux-g++
LFLAGS    =    
LIBS    =    $(SUBLIBS) -L/usr/local/arm/3.4/lib -L/home/9315/libpng-1.2.5 -L/home/9315/jpeg-6b/.libs -L/home/9315/zlib-1.2.1 -L/home/9315/tslib-0.1.1/src/.libs -L$(QTDIR)/lib -lm -lqte-mt -ldl
MOC    =    $(QTDIR)/bin/moc
UIC    =    $(QTDIR)/bin/uic


还有就是你交叉编译的时候采用的QT库应该是交叉编译后的库。
快速回复
限100 字节
 
上一个 下一个