Purpose of QcoreApplication in basic Qt console program

  c++, qt

Why does QCoreApplication a(argc, argv) exist inside main(int argc, char *argv[]) in a Qt console application? What does it do? What is its purpose?
if I remove it, a program like the following runs without issues

#include <QCoreApplication>
#include "animal.h"

int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);

    { // this is just a dummy scope for the destructor to work

        // create instances of class animal
        animal cat(NULL, "Garfield");
        animal dog(NULL, "Azor");

        // perform actions with the object's functions
        cat.weight = 10;
        qDebug() << "Cat Weight in Lbs:" << cat.weightInLbs();
        cat.speak("meow");

        // perform actions with the object's functions
        dog.weight = 35;
        qDebug() << "Dog Weight in Lbs:" << dog.weightInLbs();
        dog.speak("wooof");
     }

    //return a.exec();
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT