C1083: Cannot open include file: 'QApplication' [SOLVED]
-
wrote on 25 Mar 2013, 22:27 last edited by
I created a very simple project using "Empty Qt project" from Qt Creator.
Then I added my files to the project.Here is the .pro file
@CONFIG += qt
SOURCES +=
main.cpp
hello.cppHEADERS +=
hello.h@and here is the .h file
@#include <QPushButton>
class MyPushButton : public QPushButton
{
public:
MyPushButton(const QString &text);
};
@and here is the .cpp file
@#include <QDebug>
#include "hello.h"MyPushButton::MyPushButton(const QString &text)
: QPushButton(text)
{
setObjectName("mypushbutton");
qDebug() << "My PushButton has been constructed";
}
@and here is the main file
@#include <QApplication>
#include "hello.h"int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);MyPushButton helloButton("Hello world!"); helloButton.resize(100, 30); helloButton.show(); return app.exec();
}
@when I run the project I get the errors
C1083: Cannot open include file: 'QApplication' No such file or directory
C1083: Cannot open include file: 'QPushButton' No such file or directoryI added this line to the .pro file
@ QT += widgets @and rerun qmake and rebuild
When I run again I get no errors but the I get this
The program has unexpectedly finished.
and then nothing happens
So please HELP -
wrote on 26 Mar 2013, 00:25 last edited by
You are instantiating a QCoreApplication. For a widget based application you should be using a QApplication.
-
wrote on 26 Mar 2013, 15:34 last edited by
And, for that to work properly, make sure you have this in your .pro file:
@
qt *= core gui widgets
@ -
wrote on 27 Mar 2013, 11:54 last edited by
Thank you everybody, It was like amccarthy said.
1/4