Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Can't build official Qt tut code using Qt Creator

    General and Desktop
    4
    6
    4813
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jaggid1x last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • D
        dialingo last edited by

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

        1 Reply Last reply Reply Quote 0
        • T
          tomma last edited by

          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

          1 Reply Last reply Reply Quote 0
          • R
            romankr last edited by

            @#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.
            1 Reply Last reply Reply Quote 0
            • J
              Jaggid1x last edited by

              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

              1 Reply Last reply Reply Quote 0
              • J
                Jaggid1x last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post