Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

QApplication: No such file or directory



  • This has been asked numerous times on this and other forums and I even had this error before and it used to be resolved using said recommendations but this time no proposed solutions work.

    Basically the above title is the error I get and my .pro file is:

    @TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt

    SOURCES += main.cpp
    finddialog.cpp

    HEADERS +=
    finddialog.h
    @

    I tried adding the following with no avail:

    @QT += widgets
    QT += gui@

    Pleaas note, source code is flawless as it comes out of C++ GUI Programming with Qt 4 one of the beginning examples.



  • Don't forget to run qmake after you add Qt += widgets in the .pro file and only after that you can build the project.


  • Moderators

    Try including <QtWidgets/QApplication> if the hint from Zlatomir does not work.



  • Im not sure how to run a make file. I see numerous references oin the net and in the textbookIm using but not a step by step process on how to execute it?


  • Moderators

    If you are using Qt Creator, just go to "Build" and select "Rebuild All".

    If you are on terminal, best clean the build dir, then run:
    @
    qmake
    make
    @



  • Same error persists. "No such file or directory"



  • Are you using Qt Creator ide? If so make sure you added QT += widgets in your .pro file, than click run qmake (from the Build menu) and than build.


  • Lifetime Qt Champion

    Hi,

    In your pro file you have

    @CONFIG -= qt@

    that removes completely Qt from your project, just remove that line and run qmake again (depending on your Qt version you might need to add QT += widgets)

    Hope it helps


  • Moderators

    [quote author="SGaist" date="1364159071"]Hi,

    In your pro file you have

    @CONFIG -= qt@ [/quote]

    Hahaha! Amazing how nobody noticed that before! :D Nice catch, SGaist!



  • In QT 4.8.0, you need to include #include <QtGui/QApplication> for 5.0.1 you need to include <QtWidgets/QApplication>



  • Hi guys

    Solved:

    I included:

    @
    QT += widgets
    CONFIG += qt
    @ under .pro file

    Then to recogsnise widgets I used

    @#include <QtWidgets>@
    under the file that uses widgets

    Dont know if this makes sense as to why it works but it works...


  • Lifetime Qt Champion

    CONFIG contains qt by default, so no need to add it, just remove the "CONFIG -= qt" line from your pro file.

    Including "QtWidgets" includes in fact All headers related to the QtWidget module, that's why it works. It's cleaner to only include what you currently uses i.e <QLineEdit> or if you want a clearer separation of modules in your include part <QtWidgets/QLineEdit>.


Log in to reply