SOLVED: error: C1083: Cannot open include file: 'QtApplication': No such file or directory



  • I know this has been asked and answered before, however, here is my twist... I'm guessing a lot of people are downloading Qt 5.3 as their first attempt to learn it, like me. I have read pages of responses to the error listed above. If we do not yet know the program how do we understand the jibberish in how to fix a start-up problem. Does anybody know Qt 5.3 well enough yet to answer how to fix this error in simple, understandable terms????
    Thank you!


  • Moderators

    Hi,

    In simple terms it means that there's no such file like QtApplication in the path.
    Did you mean you wanted to include QApplication instead ?
    For that you will need to include
    @
    QT += widgets
    @

    in the .pro file.



  • included "Qt += widgets" (and also tried "QT += widgets") to the .pro file in my "gotocell1" project (built from an example that came with "C++ GUI Programming with Qt 4 book & disc) and I get the same error message.

    (the first quoted "Qt = widgets" has the correct "plus sign" in the original, but it does not print the "plus sign" in the edited, posted copy. ???Duh)


  • Moderators

    Can you post code of you .pro file and the class where you include QApplication ?
    Also try to include QApplication and not QtApplication.

    To display statements from code properly please use the coding tags '@@'



  • I'm still trying to learn how this forum form works also, so bear with me!
    The .pro file has this coding...
    @
    QT += widgets

    TEMPLATE = app
    SOURCES = main.cpp
    FORMS = gotocelldialog.ui
    @

    The main.cpp has this coding...
    @
    #include <QtApplication>
    #include <QtDialog>

    #include "ui_gotocelldialog.h"

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

    Ui::GoToCellDialog ui;
    QDialog *dialog = new QDialog;
    ui.setupUi(dialog);
    dialog->show();
    
    return app.exec();
    

    }
    @

    Hope that is the right use of @@. Trying to locate specific directions for use on here is a little tedious to say the least.



  • There is also a Forms file, but I have no idea how to copy it to here.



  • I stuck the @@'s in there, but they didn't come out in the sent response. Is that normal?


  • Moderators

    As i said earlier you must include <QApplication> instead of <QtApplication> in your main.cpp.
    No need to paste the form file. You have used the Code tags properly now.



  • I thought I tried that before. I did it now and also changed the QtDialog to Qdialog and it compiled. Thanks!!

    Did I get the @@ part right for posting code?

    Again, THANKS!



  • Disregard my last. The part of your message about the @@ code didn't come thru on the original. It only posted after I replied.


  • Moderators

    You got it right about the code tags. Also if you think your problem is solved you can edit the thread title and prepend [solved] so that others understand that the thread is solved.



  • Done. Thanks!



  • After the problem was resolved last night thanks to p3c0, I got to thinking. Was the cause due to a "Type-o" in the book, or is Qt 5.3 using new, libraries or changed names of files for the newest version?

    I've looked through the documentation on this site and haven't found anything that addresses that question.


  • Moderators

    It should be a typo.
    I just download the examples from "here":http://www.informit.com/content/images/9780132354165/examples/qt-book-examples.zip and referring to the chap02>gotocell1>main.cpp i see there's no <QtApplication> but <QApplication>
    But since Qt5 widgets is a separate module and thus you need to include
    @
    QT += widgets
    @

    in your application. And probably those examples had been coded as per Qt4.
    To get Qt5 port for these examples you can refer this "github":https://github.com/mutse/qt5-book-code link.



  • Thanks, that will probably answer a lot of my questions after I finish reading all the literature!


Log in to reply
 

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