[Solved]QString input using argv
-
maybe i should use getopt() ?
-
This doesn't do what you expect:
@for(int i=0;i<=argc;++i) {
str[i] = argv[i];@
str[i] is an QChar (and is invalid since the code QString str; constructs and empty string)You can use "QStringList":http://doc.qt.nokia.com/latest/qstringlist.html and copy each argv into a QString in the list.
LE: also QApplication has "arguments()":http://doc.qt.nokia.com/latest/qcoreapplication.html#arguments member function returns a QStringList (you pass the arguments when you construct the QApplication object: QApplication app(argc, argv);.
And it's a nice and respectful to mark the edits for your posts, else we might look like crazy people answering programming questions ;)
-
What about "QCoreApplication::arguments() ":http://doc.qt.nokia.com/4.7/qcoreapplication.html#arguments? It already parses the arguments into a QStringList.
-
Than you :)