本文整理汇总了C++中QCommandLineParser::addVersionOption方法的典型用法代码示例。如果您正苦于以下问题:C++ QCommandLineParser::addVersionOption方法的具体用法?C++ QCommandLineParser::addVersionOption怎么用?C++ QCommandLineParser::addVersionOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCommandLineParser
的用法示例。
在下文中一共展示了QCommandLineParser::addVersionOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("test"),
i18n("Test Application"),
QStringLiteral("1.0"));
QCommandLineParser parser;
KAboutData::setApplicationData(aboutData);
parser.addVersionOption();
parser.addHelpOption();
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("path"), i18n("IMAP destination path"), QStringLiteral("argument")));
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("mimetype"), i18n("Source mimetype"), QStringLiteral("argument"), QStringLiteral("application/octet-stream")));
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("file"), i18n("Source file"), QStringLiteral("argument")));
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("count"), i18n("Number of times this file is added"), QStringLiteral("argument"), QStringLiteral("1")));
//PORTING SCRIPT: adapt aboutdata variable if necessary
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
QString path = parser.value(QStringLiteral("path"));
QString mimetype = parser.value(QStringLiteral("mimetype"));
QString file = parser.value(QStringLiteral("file"));
int count = qMax(1, parser.value(QStringLiteral("count")).toInt());
ItemDumper d(path, file, mimetype, count);
return app.exec();
}
示例2: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
const QString description = QStringLiteral("Converts desktop files to json");
const char version[] = "1.0";
app.setApplicationVersion(version);
const static QString _i = QStringLiteral("input");
const static QString _o = QStringLiteral("output");
const static QString _n = QStringLiteral("name");
QCommandLineOption input = QCommandLineOption(QStringList() << QStringLiteral("i") << _i,
QStringLiteral("Read input from file"), _n);
QCommandLineOption output = QCommandLineOption(QStringList() << QStringLiteral("o") << _o,
QStringLiteral("Write output to file"), _n);
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption(description);
parser.addOption(input);
parser.addOption(output);
KConfigToJson dtj(&parser, input, output);
parser.process(app);
return dtj.runMain();
}
示例3: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
KAboutData aboutData("kdeconnect.app", i18n("Awesome App"), "1.0", i18n("KDE Connect App"), KAboutLicense::GPL, i18n("(c) 2015, Aleix Pol Gonzalez"));
aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), i18n("Maintainer"), "[email protected]");
KAboutData::setApplicationData(aboutData);
{
QCommandLineParser parser;
aboutData.setupCommandLine(&parser);
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
aboutData.processCommandLine(&parser);
}
QQmlApplicationEngine engine;
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(&engine);
kdeclarative.setupBindings();
engine.load(QUrl("qrc:/qml/main.qml"));
return app.exec();
}
示例4: main
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(mdi);
QApplication app(argc, argv);
QCoreApplication::setApplicationName("lua_debug_ui");
QCoreApplication::setOrganizationName("huangzhe");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;
parser.setApplicationDescription("lua_debug_ui");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("file", "The file to open.");
parser.process(app);
MainWindow mainWin;
if(false == mainWin.checkAndOpenFile( parser.positionalArguments().at(0), parser.positionalArguments().length() > 0))
{
return 0;
}
mainWin.show();
foreach (const QString &fileName, parser.positionalArguments())
mainWin.openFile(fileName);
return app.exec();
}
示例5: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
KAboutData about = newBrainDumpAboutData();
KAboutData::setApplicationData(about);
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
parser.process(app);
about.setupCommandLine(&parser);
about.processCommandLine(&parser);
KIconLoader::global()->addAppDir("calligra");
KoGlobal::initialize();
RootSection* doc = new RootSection;
MainWindow* window = new MainWindow(doc);
window->setVisible(true);
app.exec();
// Ensure the root section is saved
doc->sectionsIO()->save();
delete doc;
app.exit(0);
}
示例6: parse
void ApplicationSettings::parse()
{
QCommandLineParser parser;
parser.setApplicationDescription(QObject::tr("i-score - An interactive sequencer for the intermedia arts."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("file", QCoreApplication::translate("main", "Scenario to load."));
QCommandLineOption noGUI("no-gui", QCoreApplication::translate("main", "Disable GUI"));
parser.addOption(noGUI);
QCommandLineOption noRestore("no-restore", QCoreApplication::translate("main", "Disable auto-restore"));
parser.addOption(noRestore);
QCommandLineOption autoplayOpt("autoplay", QCoreApplication::translate("main", "Auto-play the loaded scenario"));
parser.addOption(autoplayOpt);
parser.process(*qApp);
const QStringList args = parser.positionalArguments();
tryToRestore = !parser.isSet(noRestore);
gui = !parser.isSet(noGUI);
autoplay = parser.isSet(autoplayOpt) && args.size() == 1;
if(!args.empty() && QFile::exists(args[0]))
{
loadList.push_back(args[0]);
}
}
示例7: commandLineArgumentsValid
bool commandLineArgumentsValid(QStringList *positionalArgs,
QStringList *ignoreMasks)
{
bool result = true;
QCommandLineParser parser;
parser.setApplicationDescription("Creates patches");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("old", QCoreApplication::translate("main", "Path to a directory containing old version of files"));
parser.addPositionalArgument("new", QCoreApplication::translate("main", "Path to a directory containing new version of files"));
parser.addPositionalArgument("result", QCoreApplication::translate("main", "Path to a directory where resulting patch will be stored"));
QCommandLineOption ignoreOption(QStringList() << "i" << "ignore",
QCoreApplication::translate("main", "Specifies which file or folder to ignore during comparison. Can be used multiple times. e.g. -i .svn -i *.txt"),
QCoreApplication::translate("main", "mask"));
parser.addOption(ignoreOption);
// Process the actual command line arguments given by the user
parser.process(*qApp);
*positionalArgs = parser.positionalArguments();
if (positionalArgs->size() < 3)
{
fputs(qPrintable(parser.helpText()), stderr);
result = false;
}
*ignoreMasks = parser.values(ignoreOption);
return result;
}
示例8: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("MyFib");
QCoreApplication::setApplicationVersion("1.1");
QCommandLineParser clap;
clap.setApplicationDescription("Calculates fibonacci numbers, slowly!");
clap.addHelpOption();
clap.addVersionOption();
const int def_n = 42;
QCommandLineOption numopt(QStringList() << "n", "number", "Number", "N");
numopt.setDefaultValue(QString::number(def_n, 10));
clap.addOption(numopt);
clap.process(app);
bool n_ok = true;
int n = clap.value(numopt).toInt(&n_ok);
MyFibCalc* calc = new MyFibCalc(&app, n_ok?n:def_n);
QObject::connect(calc, SIGNAL(done()), &app, SLOT(quit()));
QTimer::singleShot(0, calc, SLOT(calculate()));
return app.exec();
}
示例9: main
int main(int argc, char **argv)
{
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("fatcrm");
KAboutData aboutData(QStringLiteral("fatcrm"), i18n("FatCRM"),
version, i18n(description),
KAboutLicense::GPL_V2, i18n("(C) 2010-2018 KDAB"),
QString(), QStringLiteral("[email protected]"));
QCommandLineParser parser;
KAboutData::setApplicationData(aboutData);
parser.addVersionOption();
parser.addHelpOption();
QCommandLineOption noOverlayOption("nooverlay", i18n("Do not display the overlay during initial data loading"));
parser.addOption(noOverlayOption);
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
QMimeDatabase db;
if (!db.mimeTypeForName("application/x-vnd.kdab.crm.opportunity").isValid()) {
KMessageBox::error(nullptr, i18n("Mimetype application/x-vnd.kdab.crm.opportunity not found, please check your FatCRM installation"));
return 1;
}
KDBusService service(KDBusService::Multiple);
auto *window = new MainWindow(!parser.isSet(noOverlayOption));
window->setAttribute(Qt::WA_DeleteOnClose);
window->show();
return app.exec();
}
示例10: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setApplicationName("Editor");
QApplication::setApplicationVersion("1.0");
#if C3_OS == C3_OS_WINDOWS_NT
//Windows native theme looks so ugly
app.setStyle("fusion");
#endif
QCommandLineParser parser;
parser.setApplicationDescription("The Editor");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption dataDirOption("root",
"Root directory location.\nThis will override ENGINE_ROOT.",
"path");
parser.addOption(dataDirOption);
parser.process(app);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString absPath;
if(!parser.value(dataDirOption).isEmpty())
{
absPath = parser.value(dataDirOption);
}
else if(env.contains("ENGINE_ROOT"))
absPath = env.value("ENGINE_ROOT");
else
absPath = ".";
QFileInfo dirInfo(absPath);
if(!dirInfo.exists() || !dirInfo.isDir() || !QFileInfo::exists(absPath + "/Data"))
{
const char* msg = "Invalid root directory!";
QMessageBox::critical(nullptr, app.applicationName(), msg);
throw msg;
}
absPath = dirInfo.canonicalFilePath();
EngineLoader.SetRootDirectory(absPath.toUtf8().constData());
c3::RC.Loader = &EngineLoader;
c3::RC.Loader->InitEngine();
c3::FEditor EditorController;
c3::RC.Editor = &EditorController;
QSurfaceFormat format;
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(format);
MainWindow mainWindow;
c3::FLogDisplay* LogDisplay = static_cast<c3::FLogDisplay*>(EditorController.GetLogDisplay());
QObject::connect(LogDisplay, &c3::FLogDisplay::LogRefreshed,
&mainWindow, &MainWindow::OnLogChanged);
mainWindow.showMaximized();
app.exec();
}
示例11: main
int main(int argc, char **argv)
{
PrintQueue app(argc, argv);
app.setOrganizationDomain("org.kde");
KAboutData about("PrintQueue",
i18n("Print Queue"),
PM_VERSION,
i18n("Print Queue"),
KAboutLicense::GPL,
i18n("(C) 2010-2013 Daniel Nicoletti"));
about.addAuthor(QStringLiteral("Daniel Nicoletti"), QString(), "[email protected]");
about.addAuthor(QStringLiteral("Lukáš Tinkl"), i18n("Port to Qt 5 / Plasma 5"), QStringLiteral("[email protected]"));
KAboutData::setApplicationData(about);
KDBusService service(KDBusService::Unique);
QCommandLineParser parser;
about.setupCommandLine(&parser);
parser.addVersionOption();
parser.addHelpOption();
parser.addPositionalArgument("queue", i18n("Show printer queue(s)"));
parser.process(app);
about.processCommandLine(&parser);
QObject::connect(&service, &KDBusService::activateRequested, &app, &PrintQueue::showQueues);
app.showQueues(parser.positionalArguments());
return app.exec();
}
示例12: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QApplication::setApplicationName("JAERO");
QApplication::setApplicationVersion("1.0.4.4");
QCommandLineParser cmdparser;
cmdparser.setApplicationDescription("Demodulatoe and decode Satcom ACARS");
cmdparser.addHelpOption();
cmdparser.addVersionOption();
QCommandLineOption settingsnameoption(QStringList() << "s" << "settings-name",QApplication::translate("main", "Run with setting name <name>."),QApplication::translate("main", "name"));
settingsnameoption.setDefaultValue("");
cmdparser.addOption(settingsnameoption);
cmdparser.process(a);
settings_name=cmdparser.value(settingsnameoption);
if(settings_name.isEmpty())settings_name="JAERO";
else settings_name="JAERO-"+settings_name;
MainWindow w;
w.show();
return a.exec();
}
示例13: main
int main(int argc, char **argv)
{
qDebug() << "Test kinvocation by desktop name.";
KAboutData aboutData(QStringLiteral("testKInvocation"), i18n("Test for KMail invocation"), QStringLiteral("0.0"));
QCoreApplication app(argc, argv);
QCommandLineParser parser;
KAboutData::setApplicationData(aboutData);
parser.addVersionOption();
parser.addHelpOption();
aboutData.setupCommandLine(&parser);
parser.process(app);
aboutData.processCommandLine(&parser);
QString errmsg;
if (KToolInvocation::startServiceByDesktopName(QStringLiteral("org.kde.kmail"), QString(), &errmsg)) {
qDebug() << " Can not start kmail" << errmsg;
}
const QString desktopFile = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, QStringLiteral("org.kde.korganizer.desktop"));
if (KToolInvocation::startServiceByDesktopPath(desktopFile) > 0) {
qDebug() << " Can not start korganizer";
}
qDebug() << "kinvocation done.";
return 0;
}
示例14: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
#if 0
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
qInstallMessageHandler(myMessageHandler);
#else
qInstallMsgHandler(myMessageHandler);
#endif
#endif
//qDebug("hello");
//qDebug() << "world";
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
parser.process(app);
MainWindow mainWindow;
const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWindow);
mainWindow.resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
//mainWindow.show();
mainWindow.showMaximized();
QFile file("qss/stylesheet.qss");
if (!file.open(QFile::ReadOnly)) {
QMessageBox::warning(NULL, "Codecs",
QString("Cannot read file %1").arg(file.errorString()));
}
app.setStyleSheet(file.readAll());
file.close();
return app.exec();
}
示例15: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName("objects");
app.setApplicationVersion("0.1");
QCommandLineParser parser;
parser.setApplicationDescription("OpenGL objects");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption objectOption(QStringList() << "o" << "object",
QCoreApplication::translate("main", "Use object <object>."),
QCoreApplication::translate("main", "object"),
QString::fromLatin1("earth.obj"));
parser.addOption(objectOption);
QCommandLineOption shaderOption(QStringList() << "s" << "shader",
QCoreApplication::translate("main", "Use shaders <shader>.[fv].glsl."),
QCoreApplication::translate("main", "shader"),
QString::fromLatin1("simple"));
parser.addOption(shaderOption);
parser.process(app);
#ifndef QT_NO_OPENGL
MainWidget widget;
widget.setObject(parser.value(objectOption));
widget.setShader(parser.value(shaderOption));
widget.show();
#else
QLabel note("OpenGL Support required");
note.show();
#endif
return app.exec();
}