天下

记录修行的印记

QT学习笔记(3):Qt Designer设计ui及对话框使用

1) 在qt工程中的Form Files,添加MyDialog.ui,对话框的对象名为MyDialog。
2)添加1个pushButton,在Qt Designer添加信号clicked()及槽slot1()
这时,我们可以看到Qt Designer会帮我们生成 ui_MyDialog.h 
  //在ui_MyDialog.h文件中,注意这里,这是Qt Designer生成的代码
   QObject::connect(pushButton, SIGNAL(clicked()), MyDialog, SLOT(slot1()));

3.添加对应的类,并实现槽slot1()
详见附件:
/Files/aaxron/qt_deom05.rar



也可以这样:
使用Qt设计师利用布局来设置好界面,生成.ui文件,然后使用uic 
-o XXX.h XXX.ui  来生成.h 文件,然后包含这个.h 文件,自定义一个类,继承这个.h中的类,并且继承QObject 的子类,公共继承可以使用ui中的所有的界面元素

//自定义类文件
#ifndef CellDialog_H_
#define CellDialog_H_

#include 
"ui_CellDialog.h"
#include 
<QtGui/QtGui>

class GoToCellDialog :public QDialog , Ui::GoToCellDialog
{
    Q_OBJECT
public:
    GoToCellDialog(QWidget 
*parent = 0);
private slots:
    
void on_lineEdit_textChanged();
};

#endif


posted on 2012-08-26 10:11 天下 阅读(1361) 评论(0)  编辑 收藏 引用 所属分类: QT


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿(4)

随笔分类(378)

随笔档案(329)

链接

最新随笔

搜索

最新评论