Try this, which has an analogy with -I /my/include/path1 -I /my/include/path2 :
... and then you can use this method to access the values:
QStringList QCommandLineParser :: values ββ(const QString and optionName) const
Returns a list of parameter values ββfound for the given parameter name optionName, or an empty list if it is not found.
The name provided may be any long or short name of any option added using addOption ().
Here you can find a simple test case that works:
main.cpp
#include <QCoreApplication> #include <QCommandLineParser> #include <QCommandLineOption> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("multiple-values-program"); QCoreApplication::setApplicationVersion("1.0"); QCommandLineParser parser; parser.setApplicationDescription("Test helper"); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption targetDirectoryOption(QStringList() << "t" << "target-directory", QCoreApplication::translate("main", "Copy all source files into <directory>."), QCoreApplication::translate("main", "directory")); parser.addOption(targetDirectoryOption); parser.process(app); qDebug() << parser.values(targetDirectoryOption); return 0; }
main.pro
TEMPLATE = app TARGET = main QT = core SOURCES += main.cpp
Assembly and launch
qmake && make
Start and exit
./main -t foo -t bar -> ("foo", "bar") ./main -t foo bar -> ("foo")
lpapp source share