0

I noticed that the main.cpp in a Qt application has to contain the following line:

QApplication app(argc, argv).

I know that argc is the number of command-line arguments, and argv is that array list of command-line arguments. But, the question in my mind is: what are those arguments I'm passing to the constructor and at the same time cannot explicitly see? What is working behind the scences out there?

Thanks.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Caligulaminus
0

I don't work w/ Qt, so I can't say definitively. Is this a function call that must occur within your main() or is it a function definition? Since you say it's a "line", I'm guessing it's a function call from main() to the actual beginning of your applicaion.

Assuming that's the case, argc and argv are the parameters from your main function. Those parameters are populated automatically by your operating system from the information contained on the command line at program execution.

For example, if you enter the command line "program.exe /r", the value of argc will be (2) and the values of argv[0] and argv[1] will be "program.exe" and "/r" respectively.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.