Reputation: 96119
QApplication's constructor takes an (int argc, char**argv) to handle any Qt specific commandline arguments.
What if my app is in unicode? And I have a wchar_t** argv?
It seems a bit silly to create a char* copy of all the commandline args to pass to a library that is itself unicode.
Upvotes: 6
Views: 2132
Reputation: 9
Just link qtmain library.
qtmain is a helper library that enables the developer to write a cross-platform main() function on Windows. If you do not use qmake, qbs, or other build tools such as CMake, then you need to link against the qtmain library.
https://doc.qt.io/qt-5/qtmain.html
Upvotes: 0
Reputation: 72271
Well, main
will always get char** argv
, so that's what QApplication
expects. You can also convert them (using what locale/encoding?) to wide strings if you want to do other things with the command arguments.
Upvotes: 0
Reputation: 941237
Yes, it would be. If it wasn't for this note:
Warning: On Unix, this list is built from the argc and argv parameters passed to the constructor in the main() function. The string-data in argv is interpreted using QString::fromLocal8Bit(); hence it is not possible to pass, for example, Japanese command line arguments on a system that runs in a Latin1 locale. Most modern Unix systems do not have this limitation, as they are Unicode-based.
On NT-based Windows, this limitation does not apply either. On Windows, the arguments() are not built from the contents of argv/argc, as the content does not support Unicode. Instead, the arguments() are constructed from the return value of GetCommandLine(). As a result of this, the string given by arguments().at(0) might not be the program name on Windows, depending on how the application was started.
Admittedly, I don't get the word either.
Upvotes: 10