PDA

View Full Version : QApplication(argc, argv)



SWEngineer
25th April 2011, 10:11
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.

squidge
25th April 2011, 10:20
See the documentation: http://doc.qt.nokia.com/latest/qapplication.html#QApplication

You can see Qt supports several command line parameters common to all Qt applications.

SWEngineer
25th April 2011, 10:22
See the documentation: http://doc.qt.nokia.com/latest/qapplication.html#QApplication

You can see Qt supports several command line parameters common to all Qt applications.

Thanks for your reply. I mean, how can I know what is being passed? I'm mentioning that there are arguments to be passed, but, what are they, and how many arguments are being passed?

Lesiok
25th April 2011, 10:45
Read this chapter 11 (http://einstein.drexel.edu/courses/Comp_Phys/General/C_basics/). This is rudiments of C/C++.

DanH
26th April 2011, 12:36
Thanks for your reply. I mean, how can I know what is being passed? I'm mentioning that there are arguments to be passed, but, what are they, and how many arguments are being passed?

It's passing as many arguments as were on the "command line". In many cases there will be nothing beyond the first element (which is by convention the executable name).