2012-01-19 4 views
3

저는 최근에 C++ Gui Programming with Qt 4를 시작했습니다.include/Qt에서 헤더 파일을 포함하지 않습니다.

그러나 첫 번째 튜토리얼은 끝나지 않습니다. 내가 Qt는 새로운 및 컴파일에 비교적 새로운 해요으로

C:\Qt\4.8.0\andrew>qmake -project 

C:\Qt\4.8.0\andrew>qmake 

C:\Qt\4.8.0\andrew>make 
mingw32-make -f Makefile.Debug 
mingw32-make[1]: Entering directory `C:/Qt/4.8.0/andrew' 
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT - 
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE - 
DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\includ 
e\QtCore" -I"..\include\QtGui" -I"..\include" -I"." -I"..\include\ActiveQt" -I"d 
ebug" -I"..\mkspecs\win32-g++" -o debug\tutone.o tutone.cpp 
In file included from tutone.cpp:1:0: 
C:\Qt\4.8.0\include\Qt\Qapplication.h:3:10: warning: #warning "Inclusion of head 
er files from include/Qt is deprecated." [-Wcpp] 
In file included from tutone.cpp:2:0: 
C:\Qt\4.8.0\include\Qt\Qpushbutton.h:3:10: warning: #warning "Inclusion of heade 
r files from include/Qt is deprecated." [-Wcpp] 
tutone.cpp: In function 'int qMain(int, char**)': 
tutone.cpp:11:7: error: 'class QApplication' has no member named 'setMainWidget' 

mingw32-make[1]: *** [debug/tutone.o] Error 1 
mingw32-make[1]: Leaving directory `C:/Qt/4.8.0/andrew' 
mingw32-make: *** [debug] Error 2 

, 나는 오류가 내 말에 가정

#include <QApplication> 
#include <QTextEdit> 

int main(int argv, char **args) 
{ 
    QApplication app(argv, args); 

    QTextEdit textEdit; 
    textEdit.show(); 

    return app.exec(); 
} 

나는 이것을 컴파일하려고 할 때마다,이 얻을. 헤더를 틀리게 선언 했나요?

내 .PRO 파일은 다음과 같습니다 :

###################################################################### 
# Automatically generated by qmake (2.01a) Thu Jan 19 12:41:21 2012 
###################################################################### 

TEMPLATE = app 
TARGET = 
DEPENDPATH += . 
INCLUDEPATH += . 

# Input 
HEADERS += tutone.h \ 
      C:/Qt/4.8.0/include/Qt/Qapplication.h \ 
      ../include/QtGui/qapplication.h \ 
      ../src/gui/kernel/qapplication.h \ 
      C:/Qt/4.8.0/include/Qt/Qpushbutton.h \ 
      ../include/QtGui/qpushbutton.h \ 
      ../src/gui/widgets/qpushbutton.h 
SOURCES += tutone.cpp \ 
      tutthree.cpp \ 
      ../src/gui/kernel/qapplication.cpp \ 
      ../src/gui/widgets/qpushbutton.cpp 

감사

+1

방금'사용법 #include '와'사용법 #include '사용 봤어 Qt는 버그 추적기에 기록되었습니다? 아직 시도한 적은 없지만 대신 _module_로 작업하길 바랄 수 있습니다. –

+0

글쎄, 나는 그것을 시도하고 같은 결과를 얻었다. 컴파일하려고하는이 튜토리얼은 Qt 웹 사이트에서 직접 작성합니다. Qt Creator에서는 두 헤더가 모두 존재하지 않는다고 말합니다. 헤더에 대한 전체 경로를 정의해야합니까? –

+0

온라인 튜토리얼과 .pro 파일의 내용에 대한 링크를 추가 할 수 있습니까? –

답변

4

그것은 잘못된 오류입니다 인한 설치를 구축 Qt의 버그로.
그것은 문제가되지 않습니다 및

1

을 당신이 .PRO 파일에 QT 변수를 추가해야합니다 qmake -project 실행 한 후. 그럼 당신은이 이상한 헤더와 소스를 제거 (및 프로그램에 동적으로 Qt는 라이브러리를 링크) 수

QT += core gui # <-- this line 
TEMPLATE = app 
TARGET = ProjectNameHere 
DEPENDPATH += . 
INCLUDEPATH += . 

# Input 
HEADERS += tutone.h 
SOURCES += tutone.cpp \ 
     tutthree.cpp \ 
관련 문제