本文整理汇总了C++中CmdLineArgs::addOptionalArgument方法的典型用法代码示例。如果您正苦于以下问题:C++ CmdLineArgs::addOptionalArgument方法的具体用法?C++ CmdLineArgs::addOptionalArgument怎么用?C++ CmdLineArgs::addOptionalArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CmdLineArgs
的用法示例。
在下文中一共展示了CmdLineArgs::addOptionalArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
const QString errorstr = "Fatal error from the ALSA sequencer. "
"This usually happens when the kernel doesn't have ALSA support, "
"or the device node (/dev/snd/seq) doesn't exists, "
"or the kernel module (snd_seq) is not loaded. "
"Please check your ALSA/MIDI configuration.";
CmdLineArgs args;
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
args.setUsage("[options] port [bpm]");
args.addRequiredArgument("port", "Destination, MIDI port identifier");
args.addOptionalArgument("bpm", "Tempo, in beats per minute (default=120)");
args.parse(argc, argv);
try {
metronome = new Metronome();
QVariant port = args.getArgument("port");
if (!port.isNull())
metronome->subscribe(port.toString());
QVariant bpm = args.getArgument("bpm");
metronome->play(bpm.toString());
} catch (const SequencerError& ex) {
cerr << errorstr + " Returned error was: " + ex.qstrError() << endl;
} catch (...) {
cerr << errorstr << endl;
}
delete metronome;
return 0;
}
示例2: main
int main(int argc, char **argv)
{
const QString errorstr = "Fatal error from the ALSA sequencer. "
"This usually happens when the kernel doesn't have ALSA support, "
"or the device node (/dev/snd/seq) doesn't exists, "
"or the kernel module (snd_seq) is not loaded. "
"Please check your ALSA/MIDI configuration.";
CmdLineArgs args;
args.setUsage("[port]");
args.addOptionalArgument("port", "Source MIDI port");
args.parse(argc, argv);
try {
test = new QDumpMIDI();
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
QVariant portName = args.getArgument("port");
if (!portName.isNull())
test->subscribe(portName.toString());
test->run();
} catch (const SequencerError& ex) {
cerr << errorstr + " Returned error was: " + ex.qstrError() << endl;
} catch (...) {
cerr << errorstr << endl;
}
delete test;
return 0;
}