QGuiApplication - reference in argc argument
QGuiApplication have this signature in constructor:
@QGuiApplication(int & argc, char ** argv)@
But, why it need? I had derived class from QGuiApplication with signature in constructor without reference:
@MyApplication(int argc, char ** argv) : QGuiApplication(argc, argv)@
And of cource, starting at a certain point my app started to fall. I spent many time for fix this problem and now i have a question. Why it need? Integer type have equal or more than twice size than pointer, and using only once. But this reference can create similar errors, as i did.
sierdzio Moderators last edited by
A good question. I've never contemplated that. The only explanation I can think of and that carries enough weight to be mentioned, is that QCoreApplication does reserve right to modify arguments list (see "documentation":http://qt-project.org/doc/qt-4.8/qapplication.html#QApplication - QApplication is what QGuiApplication was before Qt5).
[quote]Note: argc and argv might be changed as Qt removes command line arguments that it recognizes.[/quote]
Ok, i understand. I saw this documentation eirler, but didn't see dependence with argc argument.
Chris Kawa Moderators last edited by
Theoretically you could check how many arguments Qt has processed by comparing argc value before and after QApplication creation, but honestly this is a little silly use case and I can't find better one.