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


C++ QCommandLineParser类代码示例

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


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

示例1: main

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

    QCommandLineParser commandLineParser;
    commandLineParser.addPositionalArgument(QStringLiteral("url"),
        QStringLiteral("The url to be loaded in the browser window."));
    commandLineParser.process(app);
    QStringList positionalArguments = commandLineParser.positionalArguments();

    QUrl url;
    QString year,month,outputPath;
    int day;
    if (positionalArguments.size() > 5) {
        showHelp(commandLineParser, QStringLiteral("Too many arguments."));
        return -1;
    } else if (positionalArguments.size() == 5) {
        url = QUrl::fromUserInput(positionalArguments.at(0));
        year = positionalArguments.at(1);
        month = positionalArguments.at(2);
        day = positionalArguments.at(3).toInt();
        outputPath = positionalArguments.at(4);
    }
    else
        url = QUrl("http://query.nytimes.com/search/sitesearch/#/crude+oil/from20100502to20100602/allresults/1/allauthors/relevance/business");

    if (!url.isValid()) {
        showHelp(commandLineParser, QString("%1 is not a valid url.").arg(positionalArguments.at(0)));
        return -1;
    }

    MainWindow browser(url,year,month,day,outputPath);
    browser.show();
    return app.exec();
}
开发者ID:jasonz88,项目名称:NewsGrabber,代码行数:35,代码来源:main.cpp

示例2: main

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

    QCommandLineParser optionsParser;
    optionsParser.setApplicationDescription("Tool for generating pkg file for ministaller");
    ParsedOptions options;

    switch (parseCommandLine(optionsParser, app.arguments(), options)) {
    case CommandLineOk:
        break;
    case CommandLineError:
        std::cout << optionsParser.helpText().toStdString() << std::endl;
        return 1;
    case CommandLineHelpRequested:
        std::cout << optionsParser.helpText().toStdString() << std::endl;
        return 0;
    }

    DiffGenerator diffGenerator(options.m_BaseDir, options.m_NewDir);

    diffGenerator.generateDiffs();

    std::cout << "Done" << std::endl;

    auto json = diffGenerator.generateJson();

    if (!saveJson(options.m_JsonPath, json)) {
        if (!saveJson(DEFAULT_OUTPUT_NAME, json)) {
            std::cerr << "Failed to save json to file" << std::endl;
            return 1;
        }
    }

    return 0;
}
开发者ID:Ribtoks,项目名称:heap,代码行数:35,代码来源:main.cpp

示例3: main

int main(int argc, char **argv)
{
    LXQt::SingleApplication app(argc, argv);
    app.setOrganizationName(QStringLiteral("lxqt"));
    app.setApplicationName(QStringLiteral("lxqt-config"));
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("LXQt Config"));
    const QString VERINFO = QStringLiteral(LXQT_CONFIG_VERSION
                                           "\nliblxqt   " LXQT_VERSION
                                           "\nQt        " QT_VERSION_STR);
    app.setApplicationVersion(VERINFO);
    parser.addVersionOption();
    parser.addHelpOption();
    parser.process(app);

    // ensure that we use lxqt-config.menu file.
    qputenv("XDG_MENU_PREFIX", "lxqt-");

    LXQtConfig::MainWindow w;
    app.setActivationWindow(&w);
    QSize s = QSettings{}.value("size").toSize();
    if (!s.isEmpty())
        w.resize(s);
    w.show();

    int ret = app.exec();

    QSettings{}.setValue("size", w.size());

    return ret;
}
开发者ID:rbuj,项目名称:lxqt-config,代码行数:33,代码来源:main.cpp

示例4: app

void tst_QCommandLineParser::testPositionalArguments()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    QVERIFY(parser.parse(QStringList() << "tst_qcommandlineparser" << "file.txt"));
    QCOMPARE(parser.positionalArguments(), QStringList() << QStringLiteral("file.txt"));
}
开发者ID:krysanto,项目名称:steamlink-sdk,代码行数:7,代码来源:tst_qcommandlineparser.cpp

示例5: main

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    KCrash::initialize();
    Kdelibs4ConfigMigrator migrate(QStringLiteral("kwatchgnupg"));
    migrate.setConfigFiles(QStringList() << QStringLiteral("kwatchgnupgrc"));
    migrate.setUiFiles(QStringList() << QStringLiteral("kwatchgnupgui.rc"));
    migrate.migrate();

    KLocalizedString::setApplicationDomain("kwatchgnupg");
    AboutData aboutData;

    KAboutData::setApplicationData(aboutData);
    QCommandLineParser parser;
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    KUniqueService service;

    KWatchGnuPGMainWindow *mMainWin = new KWatchGnuPGMainWindow();
    mMainWin->show();
    return app.exec();
}
开发者ID:KDE,项目名称:kleopatra,代码行数:25,代码来源:main.cpp

示例6: main

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

    try{
        FeaturesComplexNetwork cn1;
        FeaturesComplexNetwork cn2;

        auto f  = getFactories(p);
        cn1.load(p.positionalArguments()[0].toStdString().c_str(), f);
        cn2.load(p.positionalArguments()[1].toStdString().c_str(), f);



        if(compareCn(cn1, cn2, p.isSet("t")) == 0){
            puts("Equals");
        }else{
            puts("Differents");
        }
        clearFactories(f);

    }catch (std::exception *e){
        puts(e->what());
    }
    return 0;
}
开发者ID:lopespt,项目名称:PhD-Thesis,代码行数:27,代码来源:main.cpp

示例7: 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;
}
开发者ID:KDE,项目名称:kdepim,代码行数:28,代码来源:ktoolinvocationtest.cpp

示例8: 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

示例9: main

int main(int argc, char *argv[])
{
	Q_INIT_RESOURCE(application);
    QApplication * app = new QApplication(argc, argv);
	QTranslator translator;

    app->setOrganizationName("qGo");
    app->setApplicationName("qGo");

    QCommandLineParser parser;
    parser.process(*app);
    const QStringList args = parser.positionalArguments();
    translatorPtr = &translator;
	
	startqGo();
    mainwindow->show();

    QStringList::const_iterator filename;
    for ( filename = args.begin(); filename != args.end(); ++filename )
	{
        mainwindow->openSGF(*filename);
    }

	//srand(time(NULL));

    return app->exec();
}
开发者ID:xiaojianwu,项目名称:qgo,代码行数:27,代码来源:main.cpp

示例10: main

int main(int argc, char **argv)
{
    dtkDistributedApplication *app = dtkDistributed::create(argc, argv);
    app->setApplicationName("dtkDistributedSlave");
    app->setApplicationVersion("1.0.0");
    app->setOrganizationName("inria");

    QCommandLineParser *parser = app->parser();
    parser->setApplicationDescription("DTK distributed slave example application: it connect to the DTK distributed server and waits for 1 minute before exiting.");

    QCommandLineOption serverOption("server", "DTK distributed server URL", "URL");
    parser->addOption(serverOption);

    app->initialize();

     if (!parser->isSet(serverOption)) {
         qCritical() << "Error: no server set ! Use --server <url> " ;
         return 1;
     }


    // work
    slaveWork work;
    work.server = parser->value(serverOption);

    app->spawn();
    app->exec(&work);
    app->unspawn();

    return 0;
}
开发者ID:NicolasSchnitzler,项目名称:dtk,代码行数:31,代码来源:main.cpp

示例11: 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

示例12: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    KLocalizedString::setApplicationDomain("ktp-log-viewer");

    KAboutData aboutData("ktp-log-viewer",
                         i18n("KDE IM Log Viewer"),
                         QStringLiteral(KTP_TEXT_UI_VERSION_STRING));
    aboutData.addAuthor(i18n("David Edmundson"), i18n("Developer"), "[email protected]");
    aboutData.addAuthor(i18n("Daniele E. Domenichelli"), i18n("Developer"), "[email protected]");
    aboutData.addAuthor(i18n("Dan Vrátil"), i18n("Developer"), "[email protected]");
    aboutData.setProductName("telepathy/log-viewer"); //set the correct name for bug reporting
    aboutData.setOrganizationDomain(QByteArray("kde.org"));
    aboutData.setLicense(KAboutLicense::GPL_V2);

    KAboutData::setApplicationData(aboutData);

    // register to DBus
    const KDBusService dbusService(KDBusService::Multiple);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption accountId(QStringLiteral("accountID"), i18n("The UID of the account to preselect"));
    QCommandLineOption contactId(QStringLiteral("contactID"), i18n("The UID of the contact to preselect"));

    parser.addOption(accountId);
    parser.addOption(contactId);

    parser.process(app);

    Tp::registerTypes();

    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(
                                                QDBusConnection::sessionBus(),
                                                Tp::Features() << Tp::Account::FeatureCore
                                                    << Tp::Account::FeatureAvatar
                                                    << Tp::Account::FeatureProfile);

    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(
                                                QDBusConnection::sessionBus(),
                                                Tp::Features() << Tp::Connection::FeatureCore
                                                    << Tp::Connection::FeatureSelfContact
                                                    << Tp::Connection::FeatureRoster);

    Tp::ContactFactoryPtr contactFactory = KTp::ContactFactory::create(
                                                Tp::Features()  << Tp::Contact::FeatureAlias
                                                    << Tp::Contact::FeatureAvatarData
                                                    << Tp::Contact::FeatureSimplePresence
                                                    << Tp::Contact::FeatureCapabilities);

    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());

    LogViewer *logViewer = new LogViewer(accountFactory, connectionFactory, channelFactory, contactFactory);
    logViewer->show();

    return app.exec();
}
开发者ID:KDE,项目名称:ktp-text-ui,代码行数:59,代码来源:main.cpp

示例13: setupCommandLineParser

void setupCommandLineParser(QCommandLineParser& parser)
{
    parser.setApplicationDescription("Command line tool to validate 1-n XML files against a given schema.");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("schemaFile", "The path to the schema file.");
    parser.addPositionalArgument("xmlFile", "The path to an .xml file");
}
开发者ID:Blubbz0r,项目名称:XmlSchemaValidator,代码行数:8,代码来源:main.cpp

示例14: parseArgs

void CoreApplication::parseArgs()
{
    QCommandLineParser parser;
    parser.setApplicationDescription(QLatin1String("Tarsnap GUI - Online backups for the truly lazy"));
    parser.addHelpOption();
    parser.addVersionOption();
    parser.process(*this);
}
开发者ID:contian,项目名称:tarsnap-gui,代码行数:8,代码来源:coreapplication.cpp

示例15: app

void tst_QCommandLineParser::testMissingOptionValue()
{
    QCoreApplication app(empty_argc, empty_argv);
    QCommandLineParser parser;
    parser.addOption(QCommandLineOption(QStringLiteral("option"), QStringLiteral("An option"), "value"));
    QVERIFY(!parser.parse(QStringList() << "argv0" << "--option")); // the user forgot to pass a value for --option
    QCOMPARE(parser.value("option"), QString());
    QCOMPARE(parser.errorText(), QString("Missing value after '--option'."));
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:9,代码来源:tst_qcommandlineparser.cpp


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