QT 菜鸟级问题 10
我在全手工写QT程序的时候遇到问题,不能通过编译,请高手帮帮我吧!//add.h#include<qapplication.h>#include<qtextedit.h>...
我在全手工写QT程序的时候遇到问题,不能通过编译,请高手帮帮我吧!
//add.h
#include<qapplication.h>
#include<qtextedit.h>
#include<qlabel.h>
#include<qpushbutton.h>
class MyWidget:public QWidget
{
Q_OBJECT
public:
MyWidget( QWidget *parent=0, const char *name=0 );
QLabel* textLabel1;
QLabel* textLabel1_2;
QTextEdit* te_3;
QTextEdit* te_2;
QTextEdit* te_1;
QPushButton* pb_sum;
QPushButton* pb_quit;
protected slots:
virtual void languageChange();
virtual void setnum();
};
//add.cpp
#include<add.h>
QString num1,num2;
double sum;
MyWidget::MyWidget( QWidget *parent, const char *name )
:QWidget( parent, name)
{
if(!name)
{
setName("MyWidget");
}
textLabel1 = new QLabel( "+",this, "textLabel1" );
textLabel1->setGeometry( QRect( 130, 90, 20, 21 ) );
textLabel1_2 = new QLabel( "=",this, "textLabel1_2" );
textLabel1_2->setGeometry( QRect( 250, 90, 20, 21 ) );
te_3 = new QTextEdit( this, "te_3" );
te_3->setGeometry( QRect( 270, 70, 86, 58 ) );
te_2 = new QTextEdit( this, "te_2" );
te_2->setGeometry( QRect( 150, 70, 86, 58 ) );
te_1 = new QTextEdit( this, "te_1" );
te_1->setGeometry( QRect( 30, 70, 86, 58 ) );
pb_sum = new QPushButton( "SUM",this, "pb_sum" );
pb_sum->setGeometry( QRect( 30, 220, 91, 41 ) );
connect(pb_sum,SIGNAL(clicked()),this,SLOT(setnum()));
pb_quit = new QPushButton( "QUIT",this, "pb_quit" );
pb_quit->setGeometry( QRect( 150, 220, 91, 41 ) );
connect(pb_quit,SIGNAL(clicked()),this,SLOT(close()));
}
void MyWidget::setnum()
{
num1 = te_1->text();
num2 = te_2->text();
sum = num1.toDouble() + num2.toDouble();
te_3->setText(QString::number(sum));
}
int main( int argc, char **argv )
{
QApplication a( argc, argv );
MyWidget w;
a.setMainWidget( &w );
w.show();
return a.exec();
} 展开
//add.h
#include<qapplication.h>
#include<qtextedit.h>
#include<qlabel.h>
#include<qpushbutton.h>
class MyWidget:public QWidget
{
Q_OBJECT
public:
MyWidget( QWidget *parent=0, const char *name=0 );
QLabel* textLabel1;
QLabel* textLabel1_2;
QTextEdit* te_3;
QTextEdit* te_2;
QTextEdit* te_1;
QPushButton* pb_sum;
QPushButton* pb_quit;
protected slots:
virtual void languageChange();
virtual void setnum();
};
//add.cpp
#include<add.h>
QString num1,num2;
double sum;
MyWidget::MyWidget( QWidget *parent, const char *name )
:QWidget( parent, name)
{
if(!name)
{
setName("MyWidget");
}
textLabel1 = new QLabel( "+",this, "textLabel1" );
textLabel1->setGeometry( QRect( 130, 90, 20, 21 ) );
textLabel1_2 = new QLabel( "=",this, "textLabel1_2" );
textLabel1_2->setGeometry( QRect( 250, 90, 20, 21 ) );
te_3 = new QTextEdit( this, "te_3" );
te_3->setGeometry( QRect( 270, 70, 86, 58 ) );
te_2 = new QTextEdit( this, "te_2" );
te_2->setGeometry( QRect( 150, 70, 86, 58 ) );
te_1 = new QTextEdit( this, "te_1" );
te_1->setGeometry( QRect( 30, 70, 86, 58 ) );
pb_sum = new QPushButton( "SUM",this, "pb_sum" );
pb_sum->setGeometry( QRect( 30, 220, 91, 41 ) );
connect(pb_sum,SIGNAL(clicked()),this,SLOT(setnum()));
pb_quit = new QPushButton( "QUIT",this, "pb_quit" );
pb_quit->setGeometry( QRect( 150, 220, 91, 41 ) );
connect(pb_quit,SIGNAL(clicked()),this,SLOT(close()));
}
void MyWidget::setnum()
{
num1 = te_1->text();
num2 = te_2->text();
sum = num1.toDouble() + num2.toDouble();
te_3->setText(QString::number(sum));
}
int main( int argc, char **argv )
{
QApplication a( argc, argv );
MyWidget w;
a.setMainWidget( &w );
w.show();
return a.exec();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询