天嵌 ARM开发社区

 找回密码
 注册
查看: 2428|回复: 2

make编译,提示undeclared (first use this function)错误

[复制链接]
jlrq_gl 发表于 2010-7-19 20:50:11 | 显示全部楼层 |阅读模式
我按照手册上第三章步骤做QT应用程序,到make编译这一步时,编译未成功,提示如下:
[root@localhost first]# make
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/usr/lib/qt-3.1/include -I/include -o first.o first.cpp
first.cpp: In constructor `first::first(QWidget*, const char*, unsigned int)':
first.cpp:49: `PixmapLabel1' undeclared (first use this function)
first.cpp:49: (Each undeclared identifier is reported only once for each
   function it appears in.)
first.cpp:51: `image0' undeclared (first use this function)
make: *** [first.o] Error 1
似乎是提示PixmapLabel1未定义,但是first.cpp中明明已定义,请管理员帮忙,谢谢!
 楼主| jlrq_gl 发表于 2010-7-19 20:53:30 | 显示全部楼层
first.cpp的源码如下:
#include "first.h"

#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>

/*
*  Constructs a first which is a child of 'parent', with the
*  name 'name' and widget flags set to 'f'
*/
first::first( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
    if ( !name )
        setName( "first" );
    resize( 451, 305 );
    setCaption( tr( "EmbedSky_First_Qt_Program" ) );

    /*close = new QPushButton( this, "close" );
    close->setGeometry( QRect( 230, 160, 90, 32 ) );
    close->setText( tr( "Close" ) );*/

    user_b = new QPushButton( this, "user_b" );
    user_b->setGeometry( QRect( 60, 20, 100, 30 ) );
    user_b->setText( tr( "User Button" ) );

    user_t = new QLabel( this, "user_t" );
    user_t->setGeometry( QRect( 20, 70, 188, 30 ) );
    QFont user_t_font(  user_t->font() );
    /*user_t_font.setFamily( "adobe-helvetica" );*/
    user_t_font.setPointSize( 18 );
    user_t_font.setBold( TRUE );
    user_t->setFont( user_t_font );
    user_t->setText( tr( "" ) );

    PixmapLabel1=new QLabel(this,"PixmapLabel");
    PixmapLabel1->setGeometry(QRect(260,20,28,98));
    PixmapLabel1->setPixmap(image0);
    PixmapLabel1->setScaledContents(TRUE);

    close = new QPushButton( this, "close" );
    close->setGeometry( QRect( 120, 140, 80, 28 ) );
    close->setText( tr( "Close" ) );

    // signals and slots connections
    connect( user_b, SIGNAL( clicked() ), this, SLOT( user_button() ) );
    connect( close, SIGNAL( clicked() ), this, SLOT( close() ) );
}

/*  
*  Destroys the object and frees any allocated resources
*/
first::~first()
{
    // no need to delete child widgets, Qt does it all for us
}

/*  
*  Main event handler. Reimplemented to handle application
*  font changes
*/
bool first::event( QEvent* ev )
{
    bool ret = QWidget::event( ev );
    if ( ev->type() == QEvent::ApplicationFontChange ) {
        QFont user_t_font(  user_t->font() );
        /*user_t_font.setFamily( "adobe-helvetica" );*/
        user_t_font.setPointSize( 18 );
        user_t_font.setBold( TRUE );
        user_t->setFont( user_t_font );
    }
    return ret;
}

void first::user_button()
{
    user_t->setText(tr("Hello,Qt Application!"));
    //qWarning( "first::user_button(): Not implemented yet!" );
}
亚瑟王 发表于 2010-8-2 16:19:39 | 显示全部楼层
1、不要重复发帖。
2、去掉源码中的这几行:
   PixmapLabel1=new QLabel(this,"PixmapLabel");
    PixmapLabel1->setGeometry(QRect(260,20,28,98));
    PixmapLabel1->setPixmap(image0);
    PixmapLabel1->setScaledContents(TRUE);
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-10-6 02:27 , Processed in 1.043009 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表