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


C++ QQmlApplicationEngine::addImportPath方法代码示例

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


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

示例1: main

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

    QQmlApplicationEngine engine;
    engine.addImportPath(QStringLiteral("imports"));
    engine.addImportPath(QStringLiteral("assets:/imports"));
    engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));

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

示例2: main

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

    QQmlApplicationEngine engine;

    engine.addImportPath(":/qml-material/modules");
    engine.addImportPath(":/qml-extras/modules");
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

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

示例3: main

int main(int argc, char *argv[])
{
#ifdef Q_OS_IOS
    QGuiApplication app(argc, argv);
#else
    QApplication app(argc,argv);
#endif

    QQmlApplicationEngine engine;

    // Quick iOS Initialization
    engine.addImportPath("qrc:///");
    QuickIOS::registerTypes(); // It must be called before loaded any scene

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));


    QQuickWindow *window = qobject_cast<QQuickWindow *>(engine.rootObjects().first());

    /// Setup the QQuickWindow instance to fit the iOS environment
    QuickIOS::setupWindow(window);

    QuickIOS::setStatusBarStyle(QuickIOS::StatusBarStyleDefault);

    QISystemMessenger::instance()->sendMessage("activityIndicatorStart",QVariantMap());

    printSystemInformation();

    return app.exec();
}
开发者ID:0312birdzhang,项目名称:quickios,代码行数:30,代码来源:main.cpp

示例4: actionCreator_genKeyTable

void QuickFluxUnitTests::actionCreator_genKeyTable()
{
    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:///");

    QFActionCreator* actionCreator = qobject_cast<QFActionCreator*>(QFAppDispatcher::singletonObject(&engine, "QuickFluxTests" , 1,0,"AppActions"));

    QVERIFY(actionCreator);

    QString content = actionCreator->genKeyTable();

    QString output = QString(SRCDIR) + "/QuickFluxTests/AppActionsKeyTable.qml";

    QFile file(output);

    QVERIFY(file.open(QIODevice::WriteOnly));

    file.write(content.toLocal8Bit());
    file.close();

    QObject* keyTable = QFAppDispatcher::singletonObject(&engine, "QuickFluxTests",1,0,"AppActionsKeyTable");

    QVERIFY(keyTable);
    QVERIFY(keyTable->property("test1").toString() == "test1");
    QVERIFY(keyTable->property("test2").toString() == "test2");
}
开发者ID:benlau,项目名称:quickflux,代码行数:26,代码来源:quickfluxunittests.cpp

示例5: main

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.addImportPath("libview");

    // We must set the locale always to C as some tools won't work correctly without it.
    // e.g. decimal points will always be "." this way.
    QLocale::setDefault(QLocale::c());

    PythonLoader pythonLoader{&app};
    QObject* dice = pythonLoader.getObject("core.main", "Dice");
    if (!dice) {
        qDebug() << "Could not initialize the python core!";
        return -1;
    }

    QtWebEngine::initialize();
    QQmlContext* context = engine.rootContext();

    QVariant vEngine, vContext;
    vEngine.setValue(&engine);
    vContext.setValue(context);
    dice->setProperty("qmlEngine", vEngine);
    dice->setProperty("qmlContext", vContext);

    context->setContextProperty("dice", dice);
    engine.load(QUrl("libview/Window/main.qml"));
    app.topLevelWindows().first()->setIcon(QIcon("libview/Window/images/dice_logo_grey.svg"));
    return app.exec();
}
开发者ID:adam-urbanczyk,项目名称:dice-dev,代码行数:31,代码来源:main.cpp

示例6: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    app.setApplicationDisplayName("Cute App Launcher");
    app.setApplicationVersion("0.1");
    app.setApplicationName("cuteapplauncher");

    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("app",&app);
    engine.addImportPath(app.applicationDirPath() + "/imports");

    QPluginLoader loader("libs/features/libcuteplugins.so");
    if (loader.load()) {
        QQmlExtensionPlugin* plugin = qobject_cast<QQmlExtensionPlugin*>(loader.instance());
        if (plugin) {
            plugin->registerTypes("fi.leetsoftware.cute");
            plugin->initializeEngine(&engine,"fi.leetsoftware.cute");
        }
        return app.exec();
    } else {
        qDebug() << loader.errorString();
    }

    return -2;
}
开发者ID:jppiiroinen,项目名称:portfolio,代码行数:25,代码来源:main.cpp

示例7: generate

static void generate(QString package, QString name, QString path, QString header, QString source) {

    QQmlApplicationEngine engine;
    engine.addImportPath("qrc:///");
    QObject* object = QFAppDispatcher::singletonObject(&engine,package,1,0,name);
    QVERIFY(object);

    QFKeyTable* keyTable = qobject_cast<QFKeyTable*>(object);
    QVERIFY(keyTable);

    QFileInfo info;
    QString filename = path + header;

    info = QFileInfo(filename);
    QVERIFY(info.exists());
    QFile file(filename);
    QVERIFY(file.open(QIODevice::WriteOnly));
    file.write(keyTable->genHeaderFile(name).toLocal8Bit());
    file.close();

    filename = path + source;
    info = QFileInfo(filename);
    QVERIFY(info.exists());
    file.setFileName(filename);
    QVERIFY(file.open(QIODevice::WriteOnly));
    file.write(keyTable->genSourceFile(name,header).toLocal8Bit());
    file.close();
}
开发者ID:benlau,项目名称:quickflux,代码行数:28,代码来源:quickfluxunittests.cpp

示例8: main

int main(int argc, char *argv[])
{
    QGuiApplication application(argc, argv);

    QVariantMap parameters;
    QStringList args(QCoreApplication::arguments());

    if (parseArgs(args, parameters))
        return 0;
    if (!args.contains(QStringLiteral("osm.useragent")))
        parameters[QStringLiteral("osm.useragent")] = QStringLiteral("QtLocation Mapviewer example");

    QQmlApplicationEngine engine;
    engine.addImportPath(QStringLiteral(":/imports"));
    engine.load(QUrl(QStringLiteral("qrc:///mapviewer.qml")));
    QObject::connect(&engine, SIGNAL(quit()), qApp, SLOT(quit()));

    QObject *item = engine.rootObjects().first();
    Q_ASSERT(item);

    QMetaObject::invokeMethod(item, "initializeProviders",
                              Q_ARG(QVariant, QVariant::fromValue(parameters)));

    return application.exec();
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:25,代码来源:main.cpp

示例9: run_ui

void run_ui()
{
	qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
	qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
	QQmlApplicationEngine engine;
	engine.addImportPath("qrc://imports");
	DiveListModel diveListModel;
	QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(0);
	sortModel->setSourceModel(&diveListModel);
	sortModel->setDynamicSortFilter(true);
	sortModel->setSortRole(DiveListModel::DiveDateRole);
	sortModel->sort(0, Qt::DescendingOrder);
	QQmlContext *ctxt = engine.rootContext();
	ctxt->setContextProperty("diveModel", sortModel);
	engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
	qqWindowObject = engine.rootObjects().value(0);
	if (!qqWindowObject) {
		fprintf(stderr, "can't create window object\n");
		exit(1);
	}
	QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
	qml_window->setIcon(QIcon(":/subsurface-mobile-icon"));
	qqWindowObject->setProperty("messageText", QVariant("Subsurface mobile startup"));
#if !defined(Q_OS_ANDROID)
	qml_window->setHeight(1200);
	qml_window->setWidth(800);
#endif
	qml_window->show();
	qApp->exec();
}
开发者ID:getevlcted,项目名称:subsurface,代码行数:30,代码来源:subsurface-mobile-helper.cpp

示例10: main

int main(int argc, char *argv[])
{
    QGuiApplication::setApplicationName("BaasExample");


    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;


//#if defined(Q_OS_ANDROID)
    //TODO : fix registering via registerFilterTypes() Q_COREAPP_STARTUP_FUNCTION (not called with Android?)
    //registerFilterTypes();
//#endif

    qmlRegisterSingletonType( QUrl("qrc:/qml/singleton/Assets.qml"),"BaaS.Example.Assets", 1, 0,"Assets");

#ifdef APPVERSION
    engine.rootContext()->setContextProperty( "appVersion", QString( APPVERSION ));
#endif

    engine.addImportPath("qrc:///");
    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
开发者ID:a-team-fr,项目名称:QtQML-BaaS,代码行数:29,代码来源:main.cpp

示例11: main

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

    SettingsValult * settings = &Singleton<SettingsValult>::Instance();

    SettingsController settingsController;
    FileController fileController;
    SoundController soundController;
    SpeechController speechController;

    LocaleObject * uiLocale = settings->getUiLocale();
    if (uiLocale != NULL)
    {
        QLocale::setDefault(*uiLocale->locale());
    }

    QTranslator translator;
    translator.load(QLocale(), "speech-apps", "_", ":/qml/qml/i18n/", ".qm");
    app.installTranslator(&translator);

    QQmlApplicationEngine engine;
    engine.addImportPath(QApplication::applicationDirPath());
    engine.load(QUrl(QStringLiteral("qrc:/qml/qml/main.qml")));

    engine.rootContext()->setContextProperty("settingsController", &settingsController);
    engine.rootContext()->setContextProperty("fileController", &fileController);
    engine.rootContext()->setContextProperty("soundController", &soundController);
    engine.rootContext()->setContextProperty("speechController", &speechController);

    return app.exec();
}
开发者ID:delfvad,项目名称:speech-apps,代码行数:32,代码来源:main.cpp

示例12: main

/*! \brief Main method for the YARPView container.
 *
 *  \param argc
 *  \param argv
 */
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QVariant retVal;

    // De-comment this to trace all imports
    /*QByteArray data = "1";
    qputenv("QML_IMPORT_TRACE", data);*/


    QQmlApplicationEngine engine;
#ifdef WIN32
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + "\\" + PLUGINS_RELATIVE_PATH));
#else
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + "/" + PLUGINS_RELATIVE_PATH));
#endif
    engine.load(QUrl("qrc:/qml/QtYARPView/main.qml"));
    QObject *topLevel = engine.rootObjects().value(0);

    if(!topLevel){
        return 0;
    }

    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

    // Pack the argc and argv to a QStrinList so we can pass them easily to the plugin
    QStringList params;
    for(int i=1;i<argc;i++){
        params.append(argv[i]);
    }
    // Call the parseParameters of the qml object called YARPVideoSurface
    QObject *yarpVideoSurface = topLevel->findChild<QObject*>("YARPVideoSurface");
    QMetaObject::invokeMethod(yarpVideoSurface,"parseParameters",
                              Qt::DirectConnection,
                              Q_RETURN_ARG(QVariant, retVal),
                              Q_ARG(QVariant,params));
    if(!retVal.toBool()){
        return 0;
    }


    window->show();

    return app.exec();

}
开发者ID:JoErNanO,项目名称:qtyarp,代码行数:51,代码来源:main.cpp

示例13: main

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

    QQmlApplicationEngine engine;

    // Specify where to look for compiled Qimchi plugins
#ifdef Q_OS_ANDROID
    engine.addImportPath("assets:/imports");
#else
    engine.addImportPath("../imports");
#endif

    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));

    return app.exec();
}
开发者ID:qbonnard,项目名称:qimchi-preview,代码行数:17,代码来源:main.cpp

示例14: main

/*! \brief Main method for the YARPView container.
 *
 *  \param argc
 *  \param argv
 */
int main(int argc, char *argv[])
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#else
    qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
#endif
    QApplication app(argc, argv);

    QVariant retVal;

    // De-comment this to trace all imports
    /*QByteArray data = "1";
    qputenv("QML_IMPORT_TRACE", data);*/

    QQmlApplicationEngine engine;
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
                                         PLUGINS_RELATIVE_PATH));
#ifdef CMAKE_INTDIR
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
                                         ".." + QDir::separator() +
                                         PLUGINS_RELATIVE_PATH + QDir::separator() +
                                         CMAKE_INTDIR));
#endif
    engine.load(QUrl("qrc:/qml/QtYARPScope/main.qml"));
    QObject *topLevel = engine.rootObjects().value(0);
    auto* window = qobject_cast<QQuickWindow *>(topLevel);

    // Pack the argc and argv to a QStringList so we can pass them easily to the plugin
    QStringList params;
    for(int i=0;i<argc;i++){
        params.append(argv[i]);
    }
    // Call the parseParameters of the toplevel object
    QMetaObject::invokeMethod(topLevel,"parseParameters",
                              Qt::DirectConnection,
                              Q_RETURN_ARG(QVariant, retVal),
                              Q_ARG(QVariant,params));
    if(!retVal.toBool()){
        return 1;
    }

    window->show();

    return (app.exec()!=0?1:0);
}
开发者ID:robotology,项目名称:yarp,代码行数:51,代码来源:main.cpp

示例15: main

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

    // De-comment this to trace all imports
//    QByteArray data = "1";
//    qputenv("QML_IMPORT_TRACE", data);

    QQmlApplicationEngine engine;
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
                                         PLUGINS_RELATIVE_PATH));
#ifdef CMAKE_INTDIR
    engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
                                         ".." + QDir::separator() +
                                         PLUGINS_RELATIVE_PATH + QDir::separator() +
                                         CMAKE_INTDIR));
#endif

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    QObject *topLevel = engine.rootObjects().value(0);
    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

    // Pack the argc and argv to a QStrinList so we can pass them easily to the plugin
    QStringList params;
    for(int i=0;i<argc;i++){
        params.append(argv[i]);
    }
    // Call the parseParameters of the toplevel object
    QMetaObject::invokeMethod(topLevel,"parseParameters",
                              Qt::DirectConnection,
                              Q_RETURN_ARG(QVariant, retVal),
                              Q_ARG(QVariant,params));
    if(!retVal.toBool()){
        return 1;
    }

    if(window){
        window->show();
    }

    return (app.exec()!=0?1:0);
}
开发者ID:AbuMussabRaja,项目名称:icub-main,代码行数:44,代码来源:main.cpp


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