免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 863 | 回复: 0
打印 上一主题 下一主题

the three method [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-09 09:32 |只看该作者 |倒序浏览
//////////////////////////
//subclass method
///////////////////////
//form11.cpp
#include "form11.h"
#include
Form11::Form11():Form11()
{}
Form11::~Form11()
void Form11::newSlot()
{
lineEdit->setText("hellll");
}
////////////////
//form11.h
#include "form1.h"
class Form11:public Form1
{
Q_OBJECT
public:
Form11();
~Form11();
public slots:
void newSlot();
};
////////main.cpp
#include
#include "form11.h"
int main( int argc, char **argv)
{
QApplication a(argc,argv);
Form11 w;
w.show();
a.setMainWidget(&w);
//perform the same function as a.connect(&a, SIGNAL(lastWindowClosed()),
//&a, SLOT(quit()))
return a.exec();
}
//besides all above all you need is a form1.ui file, from1.ui.h is obtained
//automativcally. in the ui, you have a pushbutton with its signal clicked()
//connected to form1's slot newSlot(), and a lineedit.
/////////
//ui method
///////////

//the ui.h method to achieve the same effect
//you don't need form11.cpp or form11.h
//instead ui.h file with the folling code will do
void Form1::newSlot()
{
lineEdit->setText("hex");
}
//strange is that we do not have to include qlineedit.h, though
//the lineedit is used here.
//////////////////////
//the ui file is still the same, and the main.cpp is almost the same
#include"form1.h" //raher than form11.h
main()
{
From1 w;// no big deal
}
}
////////////////
//dynamic Window method (to be continued)

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/56913/showart_681670.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP