当前位置: 首页>>代码示例>>C++>>正文


C++ QCommandLineParser::addHelpOption方法代码示例

本文整理汇总了C++中QCommandLineParser::addHelpOption方法的典型用法代码示例。如果您正苦于以下问题:C++ QCommandLineParser::addHelpOption方法的具体用法?C++ QCommandLineParser::addHelpOption怎么用?C++ QCommandLineParser::addHelpOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QCommandLineParser的用法示例。


在下文中一共展示了QCommandLineParser::addHelpOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseCommandLine

void AppDelegate::parseCommandLine() {
    QCommandLineParser parser;
    parser.setApplicationDescription("High Fidelity Stack Manager");
    parser.addHelpOption();

    const QCommandLineOption helpOption = parser.addHelpOption();

    const QCommandLineOption hifiBuildDirectoryOption("b", "Path to build of hifi", "build-directory");
    parser.addOption(hifiBuildDirectoryOption);

    if (!parser.parse(QCoreApplication::arguments())) {
        qCritical() << parser.errorText() << endl;
        parser.showHelp();
        Q_UNREACHABLE();
    }

    if (parser.isSet(helpOption)) {
        parser.showHelp();
        Q_UNREACHABLE();
    }

    if (parser.isSet(hifiBuildDirectoryOption)) {
        const QString hifiBuildDirectory = parser.value(hifiBuildDirectoryOption);
        qDebug() << "hifiBuildDirectory=" << hifiBuildDirectory << "\n";
        GlobalData::getInstance().setHifiBuildDirectory(hifiBuildDirectory);
    }
}
开发者ID:Atlante45,项目名称:StackManagerQt,代码行数:27,代码来源:AppDelegate.cpp

示例2: 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();
}
开发者ID:KDAB,项目名称:FatCRM,代码行数:33,代码来源:main.cpp

示例3: main

int main(int argc, char **argv) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("ViewDown");
	QApplication::setApplicationVersion("1.0");
	app.setWindowIcon(QIcon("qrc:///viewdown.ico"));

	QCommandLineParser parser;
	parser.setApplicationDescription("Markdown viewer, reloading on changes.");
	parser.addPositionalArgument("file", "markdown file to view and reload on change.");
	parser.addPositionalArgument("watch", "files or directories to watch as trigger for reload.", "[watch...]");
	const QCommandLineOption styleOption("s", "css file to use as stylesheet.", "css");
	parser.addOption(styleOption);
	parser.addHelpOption();
	parser.addVersionOption();

	parser.process(app);

	QUrl styleUrl;
	if (parser.isSet(styleOption)) {
		const QString path = parser.value(styleOption);
		QFileInfo info = QFileInfo(path);
		if (info.exists())
		        styleUrl = QUrl::fromLocalFile(info.canonicalFilePath());
		else
			qWarning("No such file: %s", qPrintable(path));
	}
	if (styleUrl.isEmpty())
		styleUrl = QUrl("qrc:///github.css");

	MainWindow *browser = new MainWindow(parser.positionalArguments(), styleUrl);
	browser->show();
	return app.exec();
}
开发者ID:Cornu,项目名称:viewdown,代码行数:33,代码来源:main.cpp

示例4: main

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	QCoreApplication::setApplicationName("empire-gui");

	// Configure parser for command line arguments
	QCommandLineParser parser;
	parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
	parser.addHelpOption();
	QCommandLineOption modeOption("obs", "Start the client as observer.");
	parser.addOption(modeOption);
	QCommandLineOption addressOption("saddr", "Server address.", "port", "localhost");
	parser.addOption(addressOption);
	QCommandLineOption portOption("sport", "Server port.", "port", "0");
	parser.addOption(portOption);

	// Get arguments values
	parser.process(a);

	MainWindow w;

	// Process arguments
	QStringList args = parser.positionalArguments();
	QString address = parser.value("saddr");
	int port = parser.value("sport").toInt();
	w.initialize(address, port, parser.isSet(modeOption));
	w.show();

	return a.exec();
}
开发者ID:a-laine,项目名称:empire-gui,代码行数:30,代码来源:main.cpp

示例5: main

int main(int argc, char *argv[])
{
    LXQt::Application a(argc, argv);
    a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("LXQt OpenSSH Askpass"));
    const QString VERINFO = QStringLiteral(LXQT_ASKPASS_VERSION
                                           "\nliblxqt   " LXQT_VERSION
                                           "\nQt        " QT_VERSION_STR);
    a.setApplicationVersion(VERINFO);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.process(a);

    // TODO/FIXME: maybe a better algorithm?
    QString prompt;
    if (a.arguments().count() < 2)
        prompt = QObject::tr("unknown request");
    else
        prompt = a.arguments().at(a.arguments().count()-1);

    MainWindow w(prompt);
    w.show();

    return a.exec();
}
开发者ID:lxde,项目名称:lxqt-openssh-askpass,代码行数:27,代码来源:main.cpp

示例6: main

QT_USE_NAMESPACE

int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

    QCoreApplication::setApplicationName(QStringLiteral("qtdiag"));
    QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
    QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
    QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));

    QCommandLineParser commandLineParser;
    const QCommandLineOption noGlOption(QStringLiteral("no-gl"), QStringLiteral("Do not output GL information"));
    const QCommandLineOption glExtensionOption(QStringLiteral("gl-extensions"), QStringLiteral("List GL extensions"));
    const QCommandLineOption fontOption(QStringLiteral("fonts"), QStringLiteral("Output list of fonts"));
    commandLineParser.setApplicationDescription(QStringLiteral("Prints diagnostic output about the Qt library."));
    commandLineParser.addOption(noGlOption);
    commandLineParser.addOption(glExtensionOption);
    commandLineParser.addOption(fontOption);
    commandLineParser.addHelpOption();
    commandLineParser.process(app);
    unsigned flags = commandLineParser.isSet(noGlOption) ? 0u : unsigned(QtDiagGl);
    if (commandLineParser.isSet(glExtensionOption))
        flags |= QtDiagGlExtensions;
    if (commandLineParser.isSet(fontOption))
        flags |= QtDiagFonts;

    std::wcout << qtDiag(flags).toStdWString();
    return 0;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:30,代码来源:main.cpp

示例7: 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();
}
开发者ID:hz2769514387,项目名称:lua_debug_ui,代码行数:27,代码来源:main.cpp

示例8: 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;
}
开发者ID:geotavros,项目名称:PatchMaker,代码行数:32,代码来源:main.cpp

示例9: parse

    void Arguments::parse()
    {
        QCommandLineParser parser;
        parser.setApplicationDescription("Unit tests");
        parser.addHelpOption();

        static const QString rootOptionName = "r";
        static const QString dbOptionName   = "d";
        parser.addOptions({
            {{rootOptionName, "test_root"}, "Set tests root path. Have to be specified"   , "root"},
            {{dbOptionName  , "db_path"  }, "Set main database path. Have to be specified", "db"  },
            {"gtest_shuffle", "Shuffle tests"},
        });

        if (!parser.parse(qApp->arguments()))
            parser.showHelp();

        auto tmpRootPath = parser.value(rootOptionName);
        auto tmpDbPath   = parser.value(dbOptionName);

        if (tmpRootPath.isEmpty() || tmpDbPath.isEmpty())
            parser.showHelp();

        m_rootPath = tmpRootPath;
        m_dbPath   = tmpDbPath;
    }
开发者ID:vt4a2h,项目名称:uml-tool,代码行数:26,代码来源:Arguments.cpp

示例10: 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();
}
开发者ID:Aman8050,项目名称:kdeconnect-kde,代码行数:26,代码来源:main.cpp

示例11: 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();
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:29,代码来源:main.cpp

示例12: 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);
}
开发者ID:UIKit0,项目名称:calligra,代码行数:33,代码来源:main.cpp

示例13: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    // some command line arguments parsing stuff
    QCoreApplication::setApplicationName("ujea");
    QCoreApplication::setApplicationVersion("1.2");

    QString hostname = QHostInfo::localHostName();

    QCommandLineParser parser;
    parser.setApplicationDescription("Universal job execution agent using AMQP queue");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addOption(QCommandLineOption("aliveInterval", "Interval in ms between alive messages (1000).", "aliveInterval", "1000"));
    parser.addOption(QCommandLineOption("aliveTTL", "TTL in queue for alive messages (1500).", "aliveTTL", "1500"));
    parser.addOption(QCommandLineOption("queueCmd", "Commands queue name ("+hostname+"_cmd).", "queueCmd", hostname+"_cmd"));
    parser.addOption(QCommandLineOption("queueRpl", "Replays queue name ("+hostname+"_rpl).", "queueRpl", hostname+"_rpl"));
    parser.addOption(QCommandLineOption("execRegex", "Regex for permited commands. (none)", "execRegex", ""));
    parser.addPositionalArgument("url", QCoreApplication::translate("main", "AMQP url"));
    parser.process(app);

    const QStringList args = parser.positionalArguments();

    // we need to have 1 argument and optional named arguments
    if (args.count() != 1) parser.showHelp(-1);

    // create and execure worker
    JobsExecuter qw{QUrl(args.value(0)), parser.value("queueCmd"), parser.value("queueRpl"),
                    parser.value("aliveInterval").toInt(), parser.value("aliveTTL").toInt(),
                    parser.value("execRegex")};

    return app.exec();
}
开发者ID:kanocz,项目名称:ujea,代码行数:34,代码来源:main.cpp

示例14: main

int main(int argc, char **argv)
{
  QApplication app(argc, argv);

  KLocalizedString::setApplicationDomain("polka");

  KAboutData about( QStringLiteral("polka"), i18n("Polka"), version,
    i18n("The humane address book for the cloud"), KAboutLicense::GPL,
    i18n("(c) 2009-2015 Cornelius Schumacher"), QStringLiteral(),
    QStringLiteral("http://cornelius-schumacher.de/polka/"),
    QStringLiteral("[email protected]"));

  about.addAuthor(i18n("Cornelius Schumacher"), i18n("Creator"),
    QStringLiteral("[email protected]"));

  KAboutData::setApplicationData(about);

  QCommandLineParser parser;
  parser.addHelpOption();
  parser.addVersionOption();
  about.setupCommandLine(&parser);
  parser.process(app);
  about.processCommandLine(&parser);

  MainWindow *widget = new MainWindow;
  widget->show();

  return app.exec();
}
开发者ID:cornelius,项目名称:polka,代码行数:29,代码来源:main.cpp

示例15: 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]);
    }
}
开发者ID:himito,项目名称:i-score,代码行数:29,代码来源:ApplicationSettings.cpp


注:本文中的QCommandLineParser::addHelpOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。