Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Can't build official Qt tut code using Qt Creator
I can't build this simple code at the very beginning of the Qt tutorial
1 #include <QApplication>
2 #include <QTextEdit>
4 int main(int argv, char **args)
6 QApplication app(argv, args);
8 QTextEdit textEdit;
11 return app.exec();
It tells me
QApplication.h No such file or directory
QTextEdit.h No such file or directory
I can only imagine there's something wrong with my settings, but I'm using Qt Creator and haven't messed with anything.
dialingo last edited by
It looks like you called
use qmake for the .pro file to get a Makefile
use make to run the Makefile
This will give you an executable for your platform.
Read the relevant part of the link you specified again :-)
tomma last edited by
Can you paste your .pro -file?
It should look something like:
TEMPLATE = app
SOURCES += main.cpp
Also which version of Qt Creator are you using? And Qt?
Did you copy those line numbers to file or just some paste error?
Yeah OK faster reply was right =)
Nothing wrong with code
romankr last edited by
angle-bracket. That means that g++ will be called with -I flag.
For example, set of instructions, produced by qt creator:
@g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\qt\include\QtCore" -I"..\qt\include\QtGui" -I"..\qt\include" -I"..\qt\include\ActiveQt" -I"debug" -I"." -I"..\test" -I"." -I"..\qt\mkspecs\win32-g++" -o debug\mainwindow.o ..\test\mainwindow.cpp @
that was how include works under the hood. Why?
I'm sure that you
- haven't some qt libs (or all - installed only creator, not libs)
- have wrong qtreator settings (a wrong QT PATH) -> it's searching for includes in wrong directory.
I'm guessing it's #2 since I found QApplication in the SDK folders, but where do I set the lib directory? This is the only window I found that seems in any way associated with a lib directory:
Okay, I got it. Googled a bit to look for a way to add includes and libs onto Qt Creator. Didn't know you had to add them into the .pro file for each project =/ . Thanks for your help.