- 写相关代码
QCommandLineParser parser;
QCommandLineOption op1("a");
QCommandLineOption op2("b");
QCommandLineOption op3("c");
QCommandLineOption verboseOption("verbose");
parser.addOption(verboseOption);
parser.addOption(op1);
parser.addOption(op2);
parser.addOption(op3);
parser.process(a);
bool verbose = parser.isSet(verboseOption);
qDebug() << "verbose is set ? " << verbose;
qDebug() << "a is set ? " << parser.isSet(op1);
qDebug() << "b is set ? " << parser.isSet(op2);
qDebug() << "c is set ? " << parser.isSet(op3);
- 在命令行中执行
短命令用 -a
长命令用 --verbose
也可以同时共用
