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


C++ QDeclarativeEngine类代码示例

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


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

示例1: importsMixedQmlCppPlugin

// QTBUG-17324
void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
{
    QDeclarativeEngine engine;
    engine.addImportPath(importsDirectory());

    {
    QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.qml"));

    QObject *o = component.create();
    QVERIFY2(o, msgComponentError(component, &engine).constData());
    QCOMPARE(o->property("test").toBool(), true);
    delete o;
    }

    {
    QDeclarativeComponent component(&engine, testFileUrl("importsMixedQmlCppPlugin.2.qml"));

    QObject *o = component.create();
    QVERIFY(o != 0);
    QCOMPARE(o->property("test").toBool(), true);
    QCOMPARE(o->property("test2").toBool(), true);
    delete o;
    }


}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:27,代码来源:tst_qdeclarativemoduleplugin.cpp

示例2: main

int main(int argc, char **argv)
{
    qRegisterMetaType<QVector<QFileInfo> >();
    qmlRegisterType<DirModel>("FBrowser", 1, 0, "DirModel");
    QApplication a(argc, argv);

    QDeclarativeView v;

    QDeclarativeEngine *e = v.engine();
    e->addImageProvider(QLatin1String("nemoThumbnail"), new FileThumbnailImageProvider);

    QDeclarativeContext *c = v.rootContext();
    c->setContextProperty("fileBrowserUtils", new Utils);

    if (QFile::exists("main.qml"))
        v.setSource(QUrl::fromLocalFile("main.qml"));
    else
        v.setSource(QUrl("qrc:/qml/main.qml"));

    if (QCoreApplication::arguments().contains("-fullscreen")) {
        qDebug() << Q_FUNC_INFO << "Starting in fullscreen mode";
        v.showFullScreen();
    } else {
        qDebug() << Q_FUNC_INFO << "Starting in windowed mode";
        v.show();
    }

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

示例3: incorrectPluginCase

void tst_qdeclarativemoduleplugin::incorrectPluginCase()
{
    QDeclarativeEngine engine;
    engine.addImportPath(importsDirectory());

    QDeclarativeComponent component(&engine, testFileUrl("incorrectCase.qml"));

    QList<QDeclarativeError> errors = component.errors();
    QCOMPARE(errors.count(), 1);

    QString expectedError = QLatin1String("module \"org.qtproject.WrongCase\" plugin \"PluGin\" not found");

#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
    bool caseSensitive = true;
#if defined(Q_OS_MAC)
    caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE);
    QString libname = "libPluGin.dylib";
#elif defined(Q_OS_WIN32)
    caseSensitive = false;
    QString libname = "PluGin.dll";
#endif
    if (!caseSensitive)
        expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + QDir(importsDirectory()).filePath("org/qtproject/WrongCase/" + libname) + QLatin1String("\"");
#endif

    QCOMPARE(errors.at(0).description(), expectedError);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:27,代码来源:tst_qdeclarativemoduleplugin.cpp

示例4: QObject

SFAbstractApplicationUI::SFAbstractApplicationUI(bb::cascades::Application *app) : QObject(app) {

	//register meta types for SF classes and enums
	sfRegisterMetaTypes();

	//Setup SFDC connection info
	SFAccountManager::setClientId(SFRemoteAccessConsumerKey);
	SFAccountManager::setRedirectUri(SFOAuthRedirectURI);
	//In addition, you can set up scope for your token like below.
	/*
	QList<QString> scopes;
	scopes.append("api");
	SFAccountManager::setScopes(scopes);
	*/

	//setup API objects
	SFRestAPI::instance()->setApiVersion(SFDefaultRestApiVersion);

	//Expose API objects to QML
	QDeclarativeEngine *engine = QmlDocument::defaultDeclarativeEngine();
	QDeclarativeContext *context = engine ? engine->rootContext() : NULL;
	if (context) {
		context->setContextProperty("SFAccountManager", SFAccountManager::instance());
		context->setContextProperty("SFAuthenticationManager", SFAuthenticationManager::instance());
		context->setContextProperty("SFRestAPI", SFRestAPI::instance());
	} else {
		sfWarning() << "[SFAbstractApplicationUI] Failed to grab shared QML declarative engine. SF APIs may not be accessible in QML.";
	}

	//connect some slots
	connect(app, SIGNAL(aboutToQuit()), SFAuthenticationManager::instance(), SLOT(onAboutToQuit()));
	connect(app, SIGNAL(fullscreen()), SFAuthenticationManager::instance(), SLOT(onAppStart()));
}
开发者ID:blackberry,项目名称:BlackBerry10SDK-for-SalesforceMobile,代码行数:33,代码来源:SFAbstractApplicationUI.cpp

示例5: spy

void tst_QDeclarativePropertyMap::changed()
{
    QDeclarativePropertyMap map;
    QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
    map.insert(QLatin1String("key1"),100);
    map.insert(QLatin1String("key2"),200);
    QCOMPARE(spy.count(), 0);

    map.clear(QLatin1String("key1"));
    QCOMPARE(spy.count(), 0);

    //make changes in QML
    QDeclarativeEngine engine;
    QDeclarativeContext *ctxt = engine.rootContext();
    ctxt->setContextProperty(QLatin1String("testdata"), &map);
    QDeclarativeComponent component(&engine);
    component.setData("import QtQuick 1.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
            QUrl::fromLocalFile(""));
    QVERIFY(component.isReady());
    QDeclarativeText *txt = qobject_cast<QDeclarativeText*>(component.create());
    QVERIFY(txt);
    QCOMPARE(txt->text(), QString('X'));
    QCOMPARE(spy.count(), 1);
    QList<QVariant> arguments = spy.takeFirst();
    QCOMPARE(arguments.count(), 2);
    QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
    QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
    QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:29,代码来源:tst_qdeclarativepropertymap.cpp

示例6: main

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

    QDeclarativeView view;

    QDeclarativeEngine *engine = view.engine();

    AccelerometerReader reader;

    engine->rootContext()->setContextProperty("accelerometerReader", &reader);

    view.setSource(QUrl("qrc:/Gui.qml"));
    view.setResizeMode(QDeclarativeView::SizeRootObjectToView);

#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR)
    view.setGeometry(QApplication::desktop()->screenGeometry());
    view.showFullScreen();
#else
    view.setGeometry((QRect(100, 100, 800, 480)));
    view.show();
#endif

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

示例7: importsMixedQmlCppPlugin

// QTBUG-17324
void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
{
    QDeclarativeEngine engine;
    engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));

    {
    QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.qml"));

    QObject *o = component.create();
    QVERIFY(o != 0);
    QCOMPARE(o->property("test").toBool(), true);
    delete o;
    }

    {
    QDeclarativeComponent component(&engine, TEST_FILE("data/importsMixedQmlCppPlugin.2.qml"));

    QObject *o = component.create();
    QVERIFY(o != 0);
    QCOMPARE(o->property("test").toBool(), true);
    QCOMPARE(o->property("test2").toBool(), true);
    delete o;
    }


}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:27,代码来源:tst_qdeclarativemoduleplugin.cpp

示例8: DockModeWindow

DockModeClockWindow::DockModeClockWindow(const QPixmap& pixmap, DockModeWindowManager* dm, int zValue)
	: DockModeWindow (WindowType::Type_DockModeWindow, pixmap)
{
	setFlag (QGraphicsItem::ItemHasNoContents);
	setBoundingRect (pixmap.width(), pixmap.height());

	setName (LOCALIZED("Time"));
	setAppId ("com.palm.dockmodetime");

	QDeclarativeEngine* qmlEngine = WindowServer::instance()->declarativeEngine();
	if(qmlEngine) {
		QDeclarativeContext* context =	qmlEngine->rootContext();
		Settings* settings = Settings::LunaSettings();
		std::string systemMenuQmlPath = settings->lunaQmlUiComponentsPath + "DockModeTime/Clocks.qml";
		QUrl url = QUrl::fromLocalFile(systemMenuQmlPath.c_str());
		m_qmlNotifMenu = new QDeclarativeComponent(qmlEngine, url, this);
		if(m_qmlNotifMenu) {
			m_clockObject = qobject_cast<QGraphicsObject *>(m_qmlNotifMenu->create());
			if(m_clockObject) {
				m_clockObject->setPos (boundingRect().x(), boundingRect().y());
				m_clockObject->setParentItem(this);
			}
		}
	}
}
开发者ID:KyleMaas,项目名称:luna-sysmgr,代码行数:25,代码来源:DockModeClock.cpp

示例9: QGraphicsView

MainWindow::MainWindow(QGraphicsScene *parent) :
    QGraphicsView(parent) {

    QGraphicsScene *mainScene = new QGraphicsScene;
    setScene(mainScene);
    setFrameShape(QFrame::NoFrame);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    setCacheMode( QGraphicsView::CacheBackground );
    setAttribute(Qt::WA_TranslucentBackground, false);
    setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern));

    QDir templateDir = QApplication::applicationDirPath();
    templateDir.cdUp();
    templateDir.cd("app");

    qDebug() << "Loading file: " << templateDir.filePath("index.html");

    QGraphicsScene *scene = new QGraphicsScene;
    QDeclarativeEngine *engine = new QDeclarativeEngine;
    QDeclarativeComponent component(engine, QUrl::fromLocalFile(QApplication::applicationDirPath() + QLatin1String("/../qml/browser.qml")));
    qDebug() << component.errors();

    notifier = new Notifier();
    QObject *comp = component.create();
    QMLDialog = comp->findChild<QDeclarativeItem*>("dialog");
    QMLGallery = comp->findChild<QDeclarativeItem*>("gallery");
    QMLWebView = comp->findChild<QDeclarativeItem*>("webView");
    engine->rootContext()->setContextProperty("notifier", notifier);

    ((QDeclarativeWebView*) QMLWebView)->setPage(new WebPage());
    QMLWebView->setProperty("pageUrl", "../app/index.html");
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->settings()->enablePersistentStorage();
    QMLWebView->setCacheMode(QGraphicsItem::DeviceCoordinateCache);

    new Extensions(((QDeclarativeWebView*) QMLWebView));

    scene->addItem(qobject_cast<QGraphicsItem*>(comp));
    scene->setSceneRect(0,0,width(),height());
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);

    QMLView = new QGraphicsView( this );
    QMLView->setScene( scene );
    QMLView->setGeometry(0,0,width(),height());
    QMLView->setStyleSheet( "background: transparent; border: none;" );
    QMLView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    QMLView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    QMLView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    QMLView->setCacheMode( QGraphicsView::CacheBackground );
    QMLView->setFrameShape(QFrame::NoFrame);

    ((QDeclarativeWebView*) QMLWebView)->page()->mainFrame()->evaluateJavaScript("window._nativeReady = true"); // Tell PhoneGap that init is complete.
}
开发者ID:bundyo,项目名称:phonegap,代码行数:58,代码来源:mainwindow.cpp

示例10: rootContext

void tst_qdeclarativeengine::rootContext()
{
    QDeclarativeEngine engine;

    QVERIFY(engine.rootContext());

    QCOMPARE(engine.rootContext()->engine(), &engine);
    QVERIFY(engine.rootContext()->parentContext() == 0);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qdeclarativeengine.cpp

示例11: QFETCH

void tst_qdeclarativemoduleplugin::versionNotInstalled()
{
    QFETCH(QString, file);
    QFETCH(QString, errorFile);

    QDeclarativeEngine engine;
    engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));

    QDeclarativeComponent component(&engine, TEST_FILE(file));
    VERIFY_ERRORS(errorFile.toLatin1().constData());
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:11,代码来源:tst_qdeclarativemoduleplugin.cpp

示例12: QFETCH

void tst_qdeclarativemoduleplugin::versionNotInstalled()
{
    QFETCH(QString, file);
    QFETCH(QString, errorFile);

    QDeclarativeEngine engine;
    engine.addImportPath(importsDirectory());

    QDeclarativeComponent component(&engine, testFileUrl(file));
    VERIFY_ERRORS(errorFile.toLatin1().constData());
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:11,代码来源:tst_qdeclarativemoduleplugin.cpp

示例13: alternative

static void alternative()
{
    // Alternatively, if we don't actually want to display main.qml:
//![1]
    QDeclarativeEngine engine;
    QDeclarativeContext *windowContext = new QDeclarativeContext(engine.rootContext());
    windowContext->setContextProperty("backgroundColor", QColor(Qt::yellow));

    QDeclarativeComponent component(&engine, "main.qml");
    QObject *window = component.create(windowContext);
//![1]
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:12,代码来源:main.cpp

示例14: main

QTM_USE_NAMESPACE

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("Synchroma");
    QCoreApplication::setOrganizationDomain("synchroma.com.au");
    QCoreApplication::setApplicationName("Arca");

    QScopedPointer<QApplication> app(createApplication(argc, argv));
    QmlApplicationViewer viewer;

    QDeclarativeEngine *engine = viewer.engine();
    QDeclarativeContext *context = engine->rootContext();

    DBSession session;
    session.setConsumerKey(DROPBOX_APP_KEY);
    session.setConsumerSecret(DROPBOX_APP_SECRET);

    // Have the REST client visible in the QML
    DBRestClient restClient(session);
    context->setContextProperty("restClient", &restClient);

    // TESTING
    context->setContextProperty("param", QString(argv[1]));

    // TESTING
    qDebug() << "temp dir: " << QDir::tempPath();
    qDebug() << "home dir: " << QDir::homePath();
    qDebug() << "current dir: " << QDir::currentPath();

    QServiceManager serviceManager(QService::SystemScope);
    QStringList stringList = serviceManager.findServices();
    foreach (QString interfaceName, stringList)
        qDebug() << "service interface: " << interfaceName;

    QList<QServiceInterfaceDescriptor> descriptors = serviceManager.findInterfaces();
    for (int i=0; i<descriptors.count(); i++)
    {
        QString service = descriptors[i].serviceName();

        if (descriptors[i].scope() == QService::SystemScope)
            service += " (system)";

        qDebug() << "service: " << service;
    }

    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/arca/main.qml"));
    viewer.showExpanded();

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

示例15: clearComponentCache

void tst_qdeclarativeengine::clearComponentCache()
{
    QDeclarativeEngine engine;

    // Create original qml file
    {
        QFile file("temp.qml");
        QVERIFY(file.open(QIODevice::WriteOnly));
        file.write("import QtQuick 1.0\nQtObject {\nproperty int test: 10\n}\n");
        file.close();
    }

    // Test "test" property
    {
        QDeclarativeComponent component(&engine, "temp.qml");
        QObject *obj = component.create();
        QVERIFY(obj != 0);
        QCOMPARE(obj->property("test").toInt(), 10);
        delete obj;
    }

    // Modify qml file
    {
        QFile file("temp.qml");
        QVERIFY(file.open(QIODevice::WriteOnly));
        file.write("import QtQuick 1.0\nQtObject {\nproperty int test: 11\n}\n");
        file.close();
    }

    // Test cache hit
    {
        QDeclarativeComponent component(&engine, "temp.qml");
        QObject *obj = component.create();
        QVERIFY(obj != 0);
        QCOMPARE(obj->property("test").toInt(), 10);
        delete obj;
    }

    // Clear cache
    engine.clearComponentCache();

    // Test cache refresh
    {
        QDeclarativeComponent component(&engine, "temp.qml");
        QObject *obj = component.create();
        QVERIFY(obj != 0);
        QCOMPARE(obj->property("test").toInt(), 11);
        delete obj;
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:50,代码来源:tst_qdeclarativeengine.cpp


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