What is "QApplication app(argc, argv)" trying to do?

c++, qml, qt

Solution

The line

QApplication app(argc, argv);

creates a new instance of type `QApplication` and invokes the constructor of this class. In your example, the variable `app` now stores this instance. It is somewhat (semantically) a shorthand of this:

QApplication app = QApplication(argc, argv);

Problem

``` #include <QtGui/QApplication> #include <QtDeclarative> #include "qmlapplicationviewer.h" int main(int argc, char **argv) { QApplication app(argc, argv); QmlApplicationViewer viewer; viewer.setMainQmlFile("app/native/assets/main.qml"); viewer.showFullScreen(); return app.exec(); } ``` My C++ is a bit rusty. Can someone please explain to me what is "QApplication app(argc, argv)" trying to do ? Is it trying to declare a function which takes in 2 arguments (argc and argv) and return a variable of type QApplication ?

Original source