2012-10-14
QT第一课:学写Helloworld
1.纯源码编写
1. #include<QtGui>
2. 3. 4. int main(
int argc,
char* argv[])
5. 6. {
7. 8. QApplication app(argc,argv);
9. 10. 11. QDialog* dd =
new QDialog();
//创建一个对话框 12. 13. 14. QLabel* label =
new QLabel(dd);
//加入标签文字 15. 16. label -> setText(
"Hello world!");
17. 18. 19. 20. dd -> show();
21. 22. 23. return app.exec();
24. 25. }
实现如图
2.利用UI文件
用QT desinger form做一个对话框,在图形编辑界面中,加入label
构建相应的项目
写main.cpp,然后编译。
结果类似。
学习心得:
QT果然很强大。。。
通过 为知笔记 发布
转载于:https://www.cnblogs.com/aniuer/archive/2012/10/14/2723457.html