qt的一个form1中的button被push后,怎么把它connect连接到另外一个form2,显示form2而不显示form1.
以下程序编译后会有Form2及其函数没有声明的错误,请问为什么?
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qdialog.h>
class Form1 : public QDialog
{
public:
Form1 ( QWidget *parent=0, const char *name=0 );
Form2 *Form2;
};
Form1::Form1( QWidget *parent, const char *name )
: QDialog( parent, name )
{
QPushButton *next = new QPushButton( "Next", this, "quit" );
next->setFont( QFont( "Times", 18, QFont::Bold ) );
Form2=new Form2(this);
connect( next, SIGNAL(clicked()), Form2, (form2_slot_name()) );
}
class Form2 : public QDialog
{
public:
Form2 ( QWidget *parent=0, const char *name=0 );
};
Form2::Form2( QWidget *parent, const char *name )
: QDialog( parent, name )
{
public:
Form1 *f1;
QPushButton *next2 = new QPushButton( "Next2", this, "quit" );
next2->setFont( QFont( "Times", 18, QFont::Bold ) );
f1=new Form1(this);
void form2_slot_name();
}
void Form2::form2_slot_name()
{
if(f1->isShown())
f1->hide();
show();
}
int main( int argc, char **argv )
{
QApplication a( argc, argv );
Form1 w;
a.setMainWidget( &w );
w.show();
return a.exec();
}