职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 1226|回复: 1

QT 菜鸟级问题

[复制链接]
starzhou2 发表于 2009-8-30 10:54 | 显示全部楼层 |阅读模式
我在全手工写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 )
Widget( 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();
}
平凡人 发表于 2009-8-30 10:55 | 显示全部楼层

QT 菜鸟级问题

编译的错误怎么不贴出来
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-4-20 04:53 , Processed in 0.119798 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表