초보자 : [급합니다.] QT에서 Q_OBJECT 사용시 실행파일이 안생겨요?
안녕하세요.
QT를 처음하는 초보자 입니다.
기본적인 것인데 도저히 모르겠습니다.
꼭 도와 주십시요. 급합니다.
-------------------------------
제가 하고자 하는 파일은 finddialog.h, finddialog.cpp, main.cpp로 구성되어 있으며,
이 파일을 다음과 같이 컴파일 하였습니다.
qmake -project
qmake
make
그런데 컴파일 결과는 에러가 없는 것으로 나타났는데, debug 폴더내에는 .o (object 파일)만
생기고
실행파일이 생기지 않습니다.
제가 사용한 환경은 윈도우 xp, QT버전은 qt-win-opensource-4.4.3-mingw.exe을 설치하여 사용
하였습니다.
다른 어떤 자료를 찾아보아도 Q_OBJECT 매크로를 사용하였다 할찌라도
일반적으로 qmake와 make를 사용하면 자동으로 moc를 해 주고
실행파일이 생긴다고 하는데, 저는 도저히 안되네요.
초보자라서 부탁드립니다.
급하고요.
----------------------------
다음은 source 파일 리스트입니다.
C 드라이브의 볼륨에는 이름이 없습니다.
볼륨 일련 번호: 10F9-E790
C:\chap02\find 디렉터리
2009-09-07 오후 08:25 .
2009-09-07 오후 08:25 ..
2008-01-09 오전 08:43 1,926 finddialog.cpp
2008-01-09 오전 08:43 640 finddialog.h
2008-01-09 오전 08:43 205 main.cpp
3개 파일 2,771 바이트
2개 디렉터리 2,144,276,480 바이트 남음
----------------------
다음은 make 한 결과입니다.
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/chap02/find'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -
mthreads -Wl -Wl,-subsystem,windows -o debug\find.exe debug/finddialog.o debug/main.o
debug/moc_finddialog.o -L"c:\Qt\4.4.3\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/chap02/find'
---------------------------
다음은 debug에 생긴 결과입니다.
C 드라이브의 볼륨에는 이름이 없습니다.
볼륨 일련 번호: 10F9-E790
C:\chap02\find\debug 디렉터리
2009-09-07 오후 08:21 .
2009-09-07 오후 08:21 ..
2009-09-07 오후 08:21 1,267,768 finddialog.o
2009-09-07 오후 08:21 458,705 main.o
2009-09-07 오후 08:21 3,337 moc_finddialog.cpp
2009-09-07 오후 08:21 465,246 moc_finddialog.o
4개 파일 2,195,056 바이트
2개 디렉터리 2,142,085,120 바이트 남음
************************************************************************
아래에는 소스파일을 보여주고 있습니다.
==== finddialog.h ====
#ifndef FINDDIALOG_H
#define FINDDIALOG_H
#include
class QCheckBox;
class QLabel;
class QLineEdit;
class QPushButton;
class FindDialog : public QDialog
{
Q_OBJECT
public:
FindDialog(QWidget *parent = 0);
signals:
void findNext(const QString &str, Qt::CaseSensitivity cs);
void findPrevious(const QString &str, Qt::CaseSensitivity cs);
private slots:
void findClicked();
void enableFindButton(const QString &text);
private:
QLabel *label;
QLineEdit *lineEdit;
QCheckBox *caseCheckBox;
QCheckBox *backwardCheckBox;
QPushButton *findButton;
QPushButton *closeButton;
};
#endif
==== finddialog.cpp ====
#include
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
: QDialog(parent)
{
label = new QLabel(tr("Find &what:"));
lineEdit = new QLineEdit;
label->setBuddy(lineEdit);
caseCheckBox = new QCheckBox(tr("Match &case"));
backwardCheckBox = new QCheckBox(tr("Search &backward"));
findButton = new QPushButton(tr("&Find"));
findButton->setDefault(true);
findButton->setEnabled(false);
closeButton = new QPushButton(tr("Close"));
connect(lineEdit, SIGNAL(textChanged(const QString &)),
this, SLOT(enableFindButton(const QString &)));
connect(findButton, SIGNAL(clicked()),
this, SLOT(findClicked()));
connect(closeButton, SIGNAL(clicked()),
this, SLOT(close()));
QHBoxLayout *topLeftLayout = new QHBoxLayout;
topLeftLayout->addWidget(label);
topLeftLayout->addWidget(lineEdit);
QVBoxLayout *leftLayout = new QVBoxLayout;
leftLayout->addLayout(topLeftLayout);
leftLayout->addWidget(caseCheckBox);
leftLayout->addWidget(backwardCheckBox);
QVBoxLayout *rightLayout = new QVBoxLayout;
rightLayout->addWidget(findButton);
rightLayout->addWidget(closeButton);
rightLayout->addStretch();
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
setWindowTitle(tr("Find"));
setFixedHeight(sizeHint().height());
}
void FindDialog::findClicked()
{
QString text = lineEdit->text();
Qt::CaseSensitivity cs =
caseCheckBox->isChecked() ? Qt::CaseSensitive
: Qt::CaseInsensitive;
if (backwardCheckBox->isChecked()) {
emit findPrevious(text, cs);
} else {
emit findNext(text, cs);
}
}
void FindDialog::enableFindButton(const QString &text)
{
findButton->setEnabled(!text.isEmpty());
}
==== main.cpp ====
#include
#include "finddialog.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
FindDialog *dialog = new FindDialog;
dialog->show();
return app.exec();
}
첨부 | 파일 크기 |
---|---|
![]() | 1.36 KB |
크리에이터에서
크리에이터에서 돌려보니 목이랑 실행파일 생성되고 실행까지 되는데요
크리에이터, 이클립스, VC++, 수작업 중 무엇을 사용하시는 모르겠지만
pro 랑 Makefile을 찬 찬 히 다시 보시거나 올려주시면 도움이 되지 않을까 싶네요
댓글 달기