本帖最后由 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!" );
} |