Qt World Summit: Register Today!

New to Qt and having trouble with qmake

  • I am learning C++ and new to Qt and having trouble setting it up. I'm using C++ GUI Programming with Qt 4 since i cant seem to find anything on Qt 5. The book has me make a hello world type program to start and when it comes time to compile, I'm getting stuck. I'm using Qt 5.3 for Desktop (MinGW 4.8) command prompt to compile and I think I have the path set right.

    I have them set as ;C:\Qt\5.3\mingw482_32\bin;C:\Qt\Tools\mingw482_32\bin; under environment variables

    When I compile I follow the book and cd to folder "...\Hello" which contains Hello.cpp

    "qmake -project" creates Hello.pro and when I try to enter "qmake Hello.pro" I get

    Cannot read C:/Qt/Tools/mingw482_32/bin/g++.exe/qmake.conf: The system cannot find the path specified.
    Could not read qmake configuration file C:/Qt/Tools/mingw482_32/bin/g++.exe/qmake.conf
    Error processing project file: Hello.pro


    So I figured it out. I made the Environment Variable QMAKESPEC like the qmake manual directed me to but I had the value set wrong.

    The correct value ended up being "C:\Qt\5.3\mingw482_32\mkspecs\win32-g++"

    but now, when I get to the next step in the books compilation process, I enter "mingw32-make" and I get an error that says
    Hello.cpp:1:24: fatal error: QApplicatoin: No such file or directory
    #include <QApplication>

    compilation terminated.

    The book says that if I get this error, then I have an older version of Qt and I should get a Qt 4.1.1 or later release. The problem is that I downloaded and installed Qt a week or so ago so I should have the latest build.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You are following a Qt 4 tutorial with Qt 5. There have been some changes in between. You need to add QT += widgets to use QApplication.

    Anyway, since you are on windows and starting, you should rather use Qt Creator to create the projects, it will save you time and headaches.

  • Moderators


    I agree with SGaist. If you use Qt Creator, you won't need to worry about environment variables at all.

    Just create a project using File -> New File or Project... -> Applications -> Qt Widgets Application.

    You will also find a more up-to-date tutorial at http://qt-project.org/doc/qt-5/gettingstartedqt.html

Log in to reply