What is the minimum code for a Qt project?
-
Good evening everyone, I'm writing because I have a problem compiling minimal code on Qt Creator. To create this project, I went to file> new file or project> other projects> empty project. chose the c ++ language and I created a main.cpp file in which I wrote the following code:
#include <QApplication>
int main(int &argc, char **argv[])
{
QApplication app(argc, argv);
return app.exec();
}But the compiler threw an error saying the file <QApplication> was not found, so I tried <QApplicationStateChangeEvent>. But then the compiler generated an error saying that the variable has an incomplete type "QApplication". And I don't know how to get the project to compile, please help me?
-
@gouneken said in What is the minimum code for a Qt project?:
I went to file> new file or project> other projects> empty project.
To clarify @SGaist's post: The option you want is File > New File or Project... > Application (Qt) > Qt Widgets Application
-
@gouneken
how does your pro/cmake file look like?
maybe u jsut missing to add QtGui module? -
Hi,
To add to @raven-worx, it looks like you choose to start a non-Qt project rather than use one of the Qt specific project template hence your error.
QApplication can be found in the widgets module.
-
@gouneken said in What is the minimum code for a Qt project?:
I went to file> new file or project> other projects> empty project.
To clarify @SGaist's post: The option you want is File > New File or Project... > Application (Qt) > Qt Widgets Application