Lost my QApplication
-
Doing Qt C++ in Win 7.
I somehow am getting an error that I cannot open include file QApplicaiton -- I am following a YouTube tutorial. Help cannot find QApplicaiton either, so I suspect it has been superceded by something. How do I find out what? I'm a total novice, new to C++ and Qt. Also my knowledge of Windows esoterica is limited as well.
-
@astroannie
Hi and welcome to devnetYou do not give enough details. However, it may be your virus checker playing a role. I have had similar cases that I could start my application and the next moment I could not. The executable was gone.
If this is not the case, you need to give some details about your setup and which tutorial you are following.
-
Okay, the tutorial is C++ Qt Programming by VoidRealms -- I don't know how to get the nitty-gritty on which Qt I'm using except I downloaded it Tuesday so it's pretty new. (Help > About tells about QtCreator). And yes, I'm running Avast.
It's not my executable -- that one I can fix by logging out and logging back in again. This is an error where it says that it can't open QApplication Here's the code:
#include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication app(argc, argv); QLabel *label = new QLabel("Hello world"); label->show(); return app.exec(); }
... and here's the error:
C:\QtWorkspace\minimal\main.cpp:1: error: C1083: Cannot open include file: 'QApplications': No such file or directoryIs this more helpful?
-
Hi
Do you have a project file ?
Its often called a .pro
in that file, you might need
QT += core guiYou can also test by selecting new from menu and create new GUI application.
(just next next it)
Then run it.
If that works, your Qt is fine. -
Sorry, it's QApplication -- no s -- I typed it instead of copy/paste. I learned though -- here's my .pro file
QT += core gui SOURCES += \ main.cpp
-
ahh. ok. good catch :)
-
I told Avast to exclude my workspace. It's still not being able to find the QApplication -- same message. I even tried restarting to no avail.
(I didn't realize you could copy/paste errors -- my old IDE was wonky about that). Here is what it really says, copy/pasted for your convenience:
C:\QtWorkspace\minimal\main.cpp:1: error: C1083: Cannot open include file: 'QApplication': No such file or directory
-
@astroannie
You are using Qt creator as your new IDE?
You have the setup from your install process for Qt?In Qt creator go to menu "Tools" -> "Options" -> "Build&Run" what can you see under the different tabs?
Are there some warnings? -
@koahnig
Okay, I looked.My compiler is (not copy/pastable) Microsoft Visual C++ 10.0 (x86).
My Qt versions are 5.4.2 and 5.5.1 (both). Would removing one help?
The only thing I have warnings on is Kits -- which I didn't know I even had. They have little triangles with ! in them. One is Qt5.4.2 MSVC2010 OpenGL 32bit and the other is Qt5.5.1 MSVC2010 32-bit (default)
-
Hi and welcome to devnet,
You are missing
QT += widgets
in your .pro file.With Qt 5, the widgets have moved into their own module.
-
Bless you sir, I regret that I can thumb you up but the once.
-
No worries for that :)
Since you have it working now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know a solution has been found :)