天嵌 ARM开发社区

 找回密码
 注册
查看: 1956|回复: 1

QT第一个例子first出现的问题

[复制链接]
lvjun 发表于 2010-11-12 14:32:03 | 显示全部楼层 |阅读模式
本帖最后由 lvjun 于 2010-11-12 14:35 编辑

我在做QT2.2.0第一个例子时候出现变量未定义的错误,见附图。这里我只把first改成了自己的名字lvjun。请问什么原因导致未定义,我和教程里一样的做法。
lvjun.cpp内容如下
/****************************************************************************
** Form implementation generated from reading ui file 'lvjun.ui'
**
** Created: Fri Nov 12 10:06:28 2010
**      by:  The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "lvjun.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 lvjun which is a child of 'parent', with the
*  name 'name' and widget flags set to 'f'
*/
lvjun::lvjun( QWidget* parent,  const char* name, WFlags fl )
    : QWidget( parent, name, fl )
{
     QPixmap image0( ( const char** ) image0_data );
    if ( !name )
        setName( "lvjun" );
    resize( 410, 339 );
    setCaption( tr( "EmbedSky_lvjun" ) );

    user_b = new QPushButton( this, "user_b" );
    user_b->setGeometry( QRect( 90, 20, 110, 50 ) );
    user_b->setText( tr( "User Button" ) );

    user_t = new QLabel( this, "user_t" );
    user_t->setGeometry( QRect( 50, 90, 231, 71 ) );
    QFont user_t_font(  user_t->font() );
    user_t_font.setPointSize( 18 );
    user_t_font.setBold( TRUE );
    user_t->setFont( user_t_font );
    user_t->setText( tr( "" ) );

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

    close = new QPushButton( this, "close" );
    close->setGeometry( QRect( 230, 180, 91, 41 ) );
    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
*/
lvjun::~lvjun()
{
    // no need to delete child widgets, Qt does it all for us
}

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

void lvjun::user_button()
{
    user_t->setText( tr("Hello,lvjun!") );
// qWarning( "lvjun::user_button(): Not implemented yet!" );
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
天嵌_support1 发表于 2010-11-12 14:54:14 | 显示全部楼层
1# lvjun


都是不定义的错误,你肯定是漏了哪个自定义的头文件,而这个头文件里就是自己定义了这两个变量
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2025-8-22 18:12 , Processed in 2.036807 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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