我的程序是这样的,我用designer设计了界面文件是note.h 
#ifndef NOTE_H
#define NOTE_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QPushButton>
#include <QtGui/QTextEdit>
#include <QtGui/QWidget>
class Ui_Form
{
public:
    QPushButton *pushButton;
    QPushButton *pushButton_2;
    QTextEdit *textEdit;
    void setupUi(QWidget *Form)
    {
    Form->setObjectName(QString::fromUtf8("Form"));
    Form->setEnabled(true);
    Form->resize(QSize(220, 277).expandedTo(Form->minimumSizeHint()));
    pushButton = new QPushButton(Form);
    pushButton->setObjectName(QString::fromUtf8("pushButton"));
    pushButton->setGeometry(QRect(10, 250, 75, 23));
    pushButton_2 = new QPushButton(Form);
    pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
    pushButton_2->setGeometry(QRect(136, 250, 75, 23));
    textEdit = new QTextEdit(Form);
    textEdit->setObjectName(QString::fromUtf8("textEdit"));
    textEdit->setGeometry(QRect(10, 10, 201, 221));
    retranslateUi(Form);
    QObject::connect(pushButton_2, SIGNAL(clicked()), textEdit, SLOT(clear()));
    QObject::connect(pushButton_2, SIGNAL(clicked()), textEdit, SLOT(setFocus()));
    QMetaObject::connectSlotsByName(Form);
    } // setupUi
    void retranslateUi(QWidget *Form)
    {
    pushButton->setText(QApplication::translate("Form", "Ok"));
    pushButton_2->setText(QApplication::translate("Form", "Cance"));
    Q_UNUSED(Form);
    } // retranslateUi
};
namespace Ui {
    class Form: public Ui_Form {};
} // namespace Ui
#endif // NOTE_H
/////////////////////////////////
//         note_ok.h             //
/////////////////////////////////
#include "note.h"
using namespace Ui;
class note_ok: public Form
    {
        Q_OBJECT
    public:
        note_ok(WQidget *parent = 0);
    public slots:
        void save();
    };
/////////////////////////////////////////////
//  note_ok.cpp                               //
////////////////////////////////////////////
#include <QFile>
#include "note_ok.h"
note_ok::note_ok(WQidget *parent):Form(parent)
    {
        QObject::connect(button,SIGNAL(clicked()),textEdit,SOLT(save()));
        }
note_ok::save()
    {
        }
//////////////////////////////
//    main.cpp               //
/////////////////////////////             
#include <QApplication>
#include "note_ok.h"
int main(int argc, char **argv)
{
    QApplication app(argc,argv);    
    QWidget qwid;
    note_ok note_object;
    note_object.setupUi(&qwid);
    return app.exec();
}
文字文字[ 此贴被gongyh在2005-09-13 12:56重新编辑 ]