由 yasachi » 週四 8月 09, 2007 5:59 pm
程式如下, 不保證可以執行, 您可以參考看看
因為現在電腦上沒有qtdesign所以只好您自個兒試看看啦~:D
main.cpp
#include <QApplication>
#include "form1.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::Dialog ui;
QDialog *dialog = new QDialog();
ui.setupUi(dialog);
dialog->show();
return app.exec();
}
form1.c
/********************************************************************************
** Form generated from reading ui file 'form1.ui'
**
** Created: Mon Jan 8 11:56:40 2007
** by: Qt User Interface Compiler version 4.2.1
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef FORM1_H
#define FORM1_H
#include <QVariant>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QDialog>
#include <QDialogButtonBox>
class Ui_Dialog
{
public:
QDialogButtonBox *buttonBox;
void setupUi(QDialog *Dialog)
{
Dialog->setObjectName(QString::fromUtf8("Dialog"));
buttonBox = new QDialogButtonBox(Dialog);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(30, 240, 341, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
retranslateUi(Dialog);
QSize size(400, 300);
size = size.expandedTo(Dialog->minimumSizeHint());
Dialog->resize(size);
QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject()));
QMetaObject::connectSlotsByName(Dialog);
} // setupUi
void retranslateUi(QDialog *Dialog)
{
Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
Q_UNUSED(Dialog);
} // retranslateUi
};
namespace Ui {
class Dialog: public Ui_Dialog {};
} // namespace Ui
#endif // FORM1_H
form1.h
/********************************************************************************
** Form generated from reading ui file 'form1.ui'
**
** Created: Mon Jan 8 11:56:47 2007
** by: Qt User Interface Compiler version 4.2.1
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/
#ifndef FORM1_H
#define FORM1_H
#include <QVariant>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QDialog>
#include <QDialogButtonBox>
class Ui_Dialog
{
public:
QDialogButtonBox *buttonBox;
void setupUi(QDialog *Dialog)
{
Dialog->setObjectName(QString::fromUtf8("Dialog"));
buttonBox = new QDialogButtonBox(Dialog);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(30, 240, 341, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
retranslateUi(Dialog);
QSize size(400, 300);
size = size.expandedTo(Dialog->minimumSizeHint());
Dialog->resize(size);
QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject()));
QMetaObject::connectSlotsByName(Dialog);
} // setupUi
void retranslateUi(QDialog *Dialog)
{
Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0, QApplication::UnicodeUTF8));
Q_UNUSED(Dialog);
} // retranslateUi
};
namespace Ui {
class Dialog: public Ui_Dialog {};
} // namespace Ui
#endif // FORM1_H
makefile
# Project: Qt1
# Makefile created by Dev-C++ 4.9.9.2
CPP = g++.exe
CC = gcc.exe
WINDRES = windres.exe
RES = test1_private.res
OBJ = main.o form1.o $(RES)
LINKOBJ = main.o form1.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -L"C:/Qt/4.2.1/lib" -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -L"C:/Qt/lib" -L"C:/Qt/lib" -lmingw32 -lqtmain -lQtCore4 -lQtGui4 C:/Qt/4.2.1/lib/libQtGui4.a C:/Qt/4.2.1/lib/libQtCore4.a
INCS = -I"C:/Dev-Cpp/include" -I"C:/Qt/4.2.1/include/Qt" -I"C:/Qt/4.2.1/include/QtGui" -I"C:/Qt/4.2.1/include/QtCore"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.2.1/include" -I"C:/Qt/4.2.1/include/Qt" -I"C:/Qt/4.2.1/include/QtGui" -I"C:/Qt/4.2.1/include/QtCore"
BIN = test1.exe