Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Missing File or Directory?



  • @C:\Users\Darrel\Desktop\smartphonebrainscanner2-Brain3D\main.cpp:1: error: QtGui/QApplication: No such file or directory
    #include <QtGui/QApplication>
    ^@

    Why would this be missing...



  • Hi,

    There are 3 application types in Qt5

    QCoreApplication -> Command-Line App -> (needs module “core”)
    QGuiApplication -> Quick App -> (needs module “gui”)
    QApplication -> Widget App -> (needs module “widget”)

    You are using quick, so you may change QApplication to
    @
    #include <QtGui/QGuiApplication>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    ...
    
    return app.exec();
    

    }
    @



  • I feel like I've been dancing around this issue for awhile :-/
    4.8 -> 5.2

    Problem is that even when I use Qt 4.8 I run into more problems. I'll keep at it. Thanks for bearing with me!

    I'll have these memorized by the end of this project!



  • Wait a second so what do I do with this?

    @QScopedPointer<QApplication> app(createApplication(argc, argv));

    ...

    return app->exec();@

    to this?

    @
    QScopedPointer<QGuiApplication> app(createApplication(argc, argv));

    ...

    return app.exec();@



  • indeed,

    @
    #include <QtGui/QGuiApplication>

    int main(int argc, char *argv[])
    {
    QScopedPointer<QGuiApplication> app(createApplication(argc, argv));

    ...
    
    return app.exec();
    

    }
    @

    This would do the trick!

    But: ... I rater like to use it this way:

    @
    #include <QtGui/QGuiApplication>

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    ...
    
    return app.exec();
    

    }
    @

    As creating your app on the heap doesn't make much sense...

    when the app exits, app goes out of scope and gets deleted anyway, and stack mem is faster..

    unless there is a special reason to do it your way..!

    Both examples are valid.


Log in to reply