PDA

View Full Version : In any program, it is necessary to use QAplication app ( argc,argv)?



rezas1000
31st August 2014, 11:50
Hello
In any program, it is necessary to use QAplication app ( argc,argv)???
For example:

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
........................
........................
return app.exec();
}
thanks.

Lesiok
31st August 2014, 12:09
From QApplication doc : The QApplication class manages the GUI application's control flow and main settings. So what do you think?

rezas1000
31st August 2014, 12:28
From QApplication doc : The QApplication class manages the GUI application's control flow and main settings. So what do you think?
In fact:
Should I Use It? (Such as the use of int main(int argc,char* argv[])

anda_skoa
31st August 2014, 14:01
Are you asking whether it is necessary to have a QApplication instance or whether you have to pass argc and argv to its constructor?

Cheers,
_

rezas1000
31st August 2014, 15:32
Thank you.
Will the following code should be in every program? And if necessary.why?

Please explain some.thanks.

QApplication app(argc, argv);


return app.exec();

anda_skoa
31st August 2014, 16:16
These are necessary for all QtWidget using applications which, obviously, is only a sub section of all possible programs.

The first line creates an instance of the QApplication class, passing the program's commandline arguments to its constructor.
The second line starts the event processing loop or short "event loop" and returns the method's result as the program's exit code.

Cheers,
_