免费注册 查看新帖 |

Chinaunix

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

The techniques of using qt4-designer [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-07 19:56 |只看该作者 |倒序浏览
The techniques of using qt4-designer
This is my gained knowledge,I would like to share with all of you.
1.create .ui file,this file contain many GUI components,for example you create a dialog class called "DisplayDialog",and
added other widgets on it.And every one you all rename it.
(We assume this .ui file was sorted as name "displaydialog.ui")
We add a PushButton and a LineEdit on the main widget,set their property as follow:
QPushButton:exitButton
QLineEdit:lineEdit
Connect the signal "clicked()" of "exitButton" to the slot "accept()" of "DisplayDialog".
2.We declare a new class inherited from "DisplayDialog" designed in above .ui file.The common style as follow:
(Attention:A new file will be created automatically by qmake tool,so we include the .ui file,we should add "ui_" at the
front of the file name,)
//displaydialog.h
#ifndef DISPLAYDIALOG_H
#define DISPLAYDIALOG_H
#include
#include "ui_displaydialog.h" //the file will be created automatically by qmake
class DispDialog:public QDialog,public Ui::DisplayDialog  //inherit from Ui
{
Q_OBJECT
public:
DispDialog(QWidget *parent=0);
void setLineEditContent(QString &text);
};
3.We implement the source code in displaydialog.cpp file.
//displaydialog.cpp
#include
#include "displaydialog.h"
DispDialog::DispDialog(QWidget *parent):QDialog(parent)
{
setupUi(this);
QString tip("creatory has been succeed");
this->setLinEditContent(tip);
}
void DispDialog::setLineEditContent(QString &text);
{
lineEdit->setText(text);
}
4.The next step is to create our main.cpp file
#include
#include "displaydialog.h"
int main(int argc,char **argv)
{
QApplication app(argc,argv);
DispDialog *dialog=new DispDialog;
dialog->show();
return app.exec();
}
4.Ok,now let's to complie our application,it's so easy,thanks to qmake tools.
qmake -project
qmake
make
The remain question:
What's the funtion of the following segment:
setupUi(this);
???????????
If you know how it works ,please contact me at :creatory@163.com,Thank you!


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

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP