|
我的工程名为first,first.cpp文件内容与2010年6月版的first.cpp一样,具体程序行如下:
/****************************************************************************
** Form implementation generated from reading ui file 'first.ui'
**
** Created: Thu Jul 15 16:49:59 2010
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#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!" );
} |
|