我想做一个QT3的窗体跳转程序,因为我个人接触qt不是很久,但是因为程序的需要。所以需要通过一个界面上面的一个按钮进入另一个界面。我尝试自己做了一个简单的测试程序,编译通过了,但是运行时出问题了。请帮帮忙啊,真的有急用,先谢谢了。以下是我的程序代码:
-----------firstform.h---------------
#ifndef FIRSTFORM_H
#define FIRSTFORM_H
#include <qvariant.h>
#include <qwidget.h>
#include "./secondform.h"
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QPushButton;
class SecondForm;
class FirstForm : public QWidget
{
Q_OBJECT
public:
FirstForm( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~FirstForm();
QPushButton* showButton;
SecondForm second;
public slots:
virtual void secShow();
protected:
protected slots:
virtual void languageChange();
};
#endif // FIRSTFORM_H
----------------firstform.cpp---------------
#include "firstform.h"
#include <qvariant.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a FirstForm as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
FirstForm::FirstForm( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "FirstForm" );
showButton = new QPushButton( this, "showButton" );
showButton->setGeometry( QRect( 40, 20, 104, 32 ) );
languageChange();
resize( QSize(177, 75).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
// signals and slots connections
connect( showButton, SIGNAL( clicked() ), this, SLOT( secShow() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
FirstForm::~FirstForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void FirstForm::languageChange()
{
setCaption( tr( "first" ) );
showButton->setText( tr( "&Show" ) );
showButton->setAccel( QKeySequence( tr( "Alt+S" ) ) );
}
void FirstForm::secShow()
{
second.show();
}
}
----------------------secondform.h------------------
#ifndef SECONDFORM_H
#define SECONDFORM_H
#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class SecondForm : public QWidget
{
Q_OBJECT
public:
SecondForm( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~SecondForm();
protected:
protected slots:
virtual void languageChange();
};
#endif // SECONDFORM_H
---------------------secondform.cpp-----------------
#include "secondform.h"
#include <qvariant.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
/*
* Constructs a SecondForm as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*/
SecondForm::SecondForm( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
if ( !name )
setName( "SecondForm" );
languageChange();
resize( QSize(264, 151).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
}
/*
* Destroys the object and frees any allocated resources
*/
SecondForm::~SecondForm()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void SecondForm::languageChange()
{
setCaption( tr( "second" ) );
}
------------------main.cpp--------------
#include <qapplication.h>
#include "firstform.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
FirstForm w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
程序执行时出现的错误提示为: FirstForm::secShow(): Not implemented yet