Results 1 to 9 of 9

Thread: C1083: Cannot open include file: 'QApplication'

  1. #1
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    37
    Thanks
    14
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default C1083: Cannot open include file: 'QApplication'

    Hello,

    I'm very new to Qt.
    I just installled Qt5.0.0 & MS Visual C++ Comilper 10.0 on my compuer (running Win7)

    I tried to compile and run a few programs from the Qt Creator Examples. They work.

    Then, I created a very simple project using "Empty Qt project" from Qt Creator.
    The project was created at the default location "C:\Qt\Qt5.0.0\Tools\QtCreator\bin"
    I just added one main.cpp source file with the following code:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QPushButton button("Run");
    7. button.show()
    8. return app.exec
    9. }
    To copy to clipboard, switch view to plain text mode 
    I tried to compile it. It didn't work and it gave me: C1083: Cannot open include file: 'QApplication'.

    I looked up on the forum for similar issues and someone said: "Add the folder of the Qt include files to the paths that are used for finding headers."
    I added it to the project file (.pro), so now it looks like this:
    Qt Code:
    1. INCLUDEPATH = C:\Qt\Qt5.0.0\5.0.0\msvc2010\include
    2. SOURCES += \
    3. main.cpp
    To copy to clipboard, switch view to plain text mode 
    but it still doesn't work...Any idea to help me with this very basic code?

    Thank you in advance!

  2. The following user says thank you to Guett_31 for this useful post:


  3. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: C1083: Cannot open include file: 'QApplication'

    Add the following to your project file:
    qmake Code:
    1. QT += widgets
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following 2 users say thank you to wysota for this useful post:

    Guett_31 (6th February 2013)

  5. #3
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    37
    Thanks
    14
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C1083: Cannot open include file: 'QApplication'

    Thanks wysota.

    I did it, so my project file looks like this:
    Qt Code:
    1. QT += widgets
    2. SOURCES += \
    3. main.cpp
    To copy to clipboard, switch view to plain text mode 
    I tryed to compile without modifying the main.cpp and I got the exact same error.
    I figured out that I actually had to write:
    Qt Code:
    1. #include <QtWidgets/QApplication>
    2. #include <QtWidgets/QPushButton>
    To copy to clipboard, switch view to plain text mode 
    instead of:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    To copy to clipboard, switch view to plain text mode 
    for it to work.

    What I still don't understand is that the examples given in Qt creator use
    Qt Code:
    1. #include <QApplication>
    To copy to clipboard, switch view to plain text mode 
    and they compile without complaining.

  6. The following user says thank you to Guett_31 for this useful post:


  7. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,581
    Thanks
    13
    Thanked 1,584 Times in 1,513 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: C1083: Cannot open include file: 'QApplication'

    You neither need nor want the "QtWidgets/" portion of those #include lines; but you do need to rerun qmake after modifying the PRO file.

  8. The following 3 users say thank you to ChrisW67 for this useful post:

    china_cao (4th May 2013), Guett_31 (6th February 2013)

  9. #5
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    37
    Thanks
    14
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C1083: Cannot open include file: 'QApplication'

    Thank you very much CrisW67! It works just fine. My error was that I thought that pressing the run button in Qt creator would both run qmake and compile the code.

  10. The following user says thank you to Guett_31 for this useful post:


  11. #6
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C1083: Cannot open include file: 'QApplication'

    Hi everybody, I have the same problem, I did add
    Qt Code:
    1. QT += widgets
    To copy to clipboard, switch view to plain text mode 
    and rerun the qmake and rebuild.
    What I get is no errors ,but when I run the project it says The program has unexpectedly finished. and in the compile output this line C:\Qt\Qt5.0.1\Tools\QtCreator\bin\jom.exe -f Makefile.Debug is colored in red

  12. The following user says thank you to Baso for this useful post:


  13. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,581
    Thanks
    13
    Thanked 1,584 Times in 1,513 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: C1083: Cannot open include file: 'QApplication'

    Your code is the problem. Launch your program in your debugger and, when it crashes, look at the information available to work out where and why it crashes. If you still cannot work it out then start your own thread and actually provide some information about your program, where it is crashing, what you have tried to diagnose/fix it etc. We are not mind readers and need at least some information to go on.

  14. The following 2 users say thank you to ChrisW67 for this useful post:

    Baso (27th March 2013)

  15. #8
    Join Date
    Feb 2013
    Posts
    28
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C1083: Cannot open include file: 'QApplication'

    It worked, The error was that I used a QCoreApplication object instead of QApplication , my bad sorry

  16. The following user says thank you to Baso for this useful post:


  17. #9
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Windows Android

    Default Re: C1083: Cannot open include file: 'QApplication'

    QT +=widgets is one of assignment to qmake variable. qmake has following variables for your reference.
    CONFIG
    DEFINES
    DEF_FILE
    DEPENDPATH
    DEPLOYMENT
    DEPLOYMENT_PLUGIN
    DESTDIR
    DESTDIR_TARGET
    DLLDESTDIR
    DISTFILES
    FORMS
    GUID
    HEADERS
    ICON
    INCLUDEPATH
    INSTALLS
    LEXIMPLS
    LEXOBJECTS
    LEXSOURCES
    LIBS
    LITERAL_HASH
    MAKEFILE
    MAKEFILE_GENERATOR
    MOC_DIR
    OBJECTS
    OBJECTS_DIR
    OBJMOC
    POST_TARGETDEPS
    PRE_TARGETDEPS
    PRECOMPILED_HEADER
    PWD
    OUT_PWD
    QMAKE
    QMAKESPEC
    QMAKE_APP_FLAG
    QMAKE_APP_OR_DLL
    QMAKE_AR_CMD
    QMAKE_BUNDLE_DATA
    QMAKE_BUNDLE_EXTENSION
    QMAKE_CC
    QMAKE_CFLAGS_DEBUG
    QMAKE_CFLAGS_RELEASE
    QMAKE_CFLAGS_SHLIB
    QMAKE_CFLAGS_THREAD
    QMAKE_CFLAGS_WARN_OFF
    QMAKE_CFLAGS_WARN_ON
    QMAKE_CLEAN
    QMAKE_CXX
    QMAKE_CXXFLAGS
    QMAKE_CXXFLAGS_DEBUG
    QMAKE_CXXFLAGS_RELEASE
    QMAKE_CXXFLAGS_SHLIB
    QMAKE_CXXFLAGS_THREAD
    QMAKE_CXXFLAGS_WARN_OFF
    QMAKE_CXXFLAGS_WARN_ON
    QMAKE_DISTCLEAN
    QMAKE_EXTENSION_SHLIB
    QMAKE_EXT_MOC
    QMAKE_EXT_UI
    QMAKE_EXT_PRL
    QMAKE_EXT_LEX
    QMAKE_EXT_YACC
    QMAKE_EXT_OBJ
    QMAKE_EXT_CPP
    QMAKE_EXT_H
    QMAKE_EXTRA_COMPILERS
    QMAKE_EXTRA_TARGETS
    QMAKE_FAILED_REQUIREMENTS
    QMAKE_FRAMEWORK_BUNDLE_NAME
    QMAKE_FRAMEWORK_VERSION
    QMAKE_INCDIR
    QMAKE_INCDIR_EGL
    QMAKE_INCDIR_OPENGL
    QMAKE_INCDIR_OPENGL_ES1, QMAKE_INCDIR_OPENGL_ES2
    QMAKE_INCDIR_OPENVG
    QMAKE_INCDIR_QT
    QMAKE_INCDIR_THREAD
    QMAKE_INCDIR_X11
    QMAKE_INFO_PLIST
    QMAKE_LFLAGS
    QMAKE_LFLAGS_CONSOLE
    QMAKE_LFLAGS_DEBUG
    QMAKE_LFLAGS_PLUGIN
    QMAKE_LFLAGS_RPATH
    QMAKE_LFLAGS_QT_DLL
    QMAKE_LFLAGS_RELEASE
    QMAKE_LFLAGS_SHAPP
    QMAKE_LFLAGS_SHLIB
    QMAKE_LFLAGS_SONAME
    QMAKE_LFLAGS_THREAD
    QMAKE_LFLAGS_WINDOWS
    QMAKE_LIBDIR
    QMAKE_LIBDIR_FLAGS
    QMAKE_LIBDIR_EGL
    QMAKE_LIBDIR_OPENGL
    QMAKE_LIBDIR_OPENVG
    QMAKE_LIBDIR_QT
    QMAKE_LIBDIR_X11
    QMAKE_LIBS
    QMAKE_LIBS_EGL
    QMAKE_LIBS_OPENGL
    QMAKE_LIBS_OPENGL_QT
    QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES2
    QMAKE_LIBS_OPENVG
    QMAKE_LIBS_QT
    QMAKE_LIBS_QT_DLL
    QMAKE_LIBS_QT_OPENGL
    QMAKE_LIBS_QT_THREAD
    QMAKE_LIBS_RT
    QMAKE_LIBS_RTMT
    QMAKE_LIBS_THREAD
    QMAKE_LIBS_WINDOWS
    QMAKE_LIBS_X11
    QMAKE_LIB_FLAG
    QMAKE_LINK_SHLIB_CMD
    QMAKE_LN_SHLIB
    QMAKE_POST_LINK
    QMAKE_PRE_LINK
    QMAKE_PROJECT_NAME
    QMAKE_MAC_SDK
    QMAKE_MACOSX_DEPLOYMENT_TARGET
    QMAKE_MAKEFILE
    QMAKE_MOC_SRC
    QMAKE_QMAKE
    QMAKE_QT_DLL
    QMAKE_RESOURCE_FLAGS
    QMAKE_RPATH
    QMAKE_RPATHDIR
    QMAKE_RUN_CC
    QMAKE_RUN_CC_IMP
    QMAKE_RUN_CXX
    QMAKE_RUN_CXX_IMP
    QMAKE_TARGET
    QMAKE_UIC
    QT
    QTPLUGIN
    QT_VERSION
    QT_MAJOR_VERSION
    QT_MINOR_VERSION
    QT_PATCH_VERSION
    RC_FILE
    RC_INCLUDEPATH
    RCC_DIR
    REQUIRES
    RESOURCES
    RES_FILE
    SIGNATURE_FILE
    SOURCES
    SRCMOC
    SUBDIRS
    TARGET
    TARGET_EXT
    TARGET_x
    TARGET_x.y.z
    TEMPLATE
    TRANSLATIONS
    UICIMPLS
    UICOBJECTS
    UI_DIR
    UI_HEADERS_DIR
    UI_SOURCES_DIR
    VERSION
    VER_MAJ
    VER_MIN
    VER_PAT
    VPATH
    YACCIMPLS
    YACCOBJECTS
    YACCSOURCES
    _PRO_FILE_
    _PRO_FILE_PWD_

  18. The following user says thank you to china_cao for this useful post:


Similar Threads

  1. Can't open include file QApplication
    By Yes in forum Newbie
    Replies: 0
    Last Post: 5th November 2011, 17:55
  2. Replies: 1
    Last Post: 23rd May 2011, 05:53
  3. Replies: 3
    Last Post: 1st November 2010, 17:33
  4. Replies: 4
    Last Post: 9th May 2010, 17:18
  5. Replies: 10
    Last Post: 15th June 2009, 20:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.