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>
    3
    4 int main(int argv, char **args)
    5 {
    6 QApplication app(argv, args);
    7
    8 QTextEdit textEdit;
    9 textEdit.show();
    10
    11 return app.exec();
    12 }
    @

    from here: http://doc.qt.nokia.com/4.7/gettingstartedqt.html

    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.



  • It looks like you called
    @qmake main.cpp@

    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 :-)



  • Can you paste your .pro -file?
    It should look something like:
    @
    TEMPLATE = app
    TARGET =
    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?

    Edit:
    Yeah OK faster reply was right =)
    Nothing wrong with code



  • @#include <QTextEdit>@
    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

    1. haven't some qt libs (or all - installed only creator, not libs)
    2. 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:

    http://i.imgur.com/G7izb.jpg



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.