我用的qt4+Eclipse开发,我来说一下步骤吧,供你参考:
(ps:使用Eclipse制作界面和编程、编译)
现在,我要建立一个对话框,对话框内只有一个按钮(pushButton),点击按钮会弹出一个MessageBox.步骤如下:
1、新建一个文件夹test1,打开Eclipse制作好界面
2、在test1文件夹内添加3个文件,分别为test1.h,test1.cpp,main.cpp,在test1.h添加如下代码:
#ifndef TEST1_H
#define TEST1_H
#include <QtGui/QDialog>
#include <QStandardItemModel>
#include "ui_test3.h"
class test : public QDialog
{
Q_OBJECT
public:
test(QWidget *parent = 0);
~test();
private:
Ui_Dialog ui;
private slots:
void on_pushButton_clicked();
};
#endif
在test1.cpp中添加如下代码:
#include "test3.h"
#include <QLibrary>
#include <QMessageBox>
test::test(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
}
test::~test()
{
}
void test::on_pushButton_clicked()
{
QMessageBox::information(this,tr("hello"),tr("Hello world!"));
}
在main.cpp中添加如下代码:
#include <QtGui>
#include <QApplication>
#include "test1.h"
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
test *dialog = new test;
dialog->show();
return app.exec();
}
3、使用Eclipse进行编译、运行,就OK了。
需要知道qt+Eclipse的环境,请看我另外的一篇文章:
http://blog.chinaunix.net/u3/103745/showart_2048620.html