本文整理汇总了C++中QDeclarativeEngine::addImportPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeEngine::addImportPath方法的具体用法?C++ QDeclarativeEngine::addImportPath怎么用?C++ QDeclarativeEngine::addImportPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeEngine
的用法示例。
在下文中一共展示了QDeclarativeEngine::addImportPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: 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;
}
}
示例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);
}
示例4: versionNotInstalled
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());
}
示例5: versionNotInstalled
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());
}
示例6: component
void tst_qdeclarativemoduleplugin::importsPlugin21()
{
QDeclarativeEngine engine;
engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
QDeclarativeComponent component(&engine, TEST_FILE("data/works21.qml"));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("value").toInt(),123);
delete object;
}
示例7: component
void tst_qdeclarativemoduleplugin::importsPlugin21()
{
QDeclarativeEngine engine;
engine.addImportPath(importsDirectory());
QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
QDeclarativeComponent component(&engine, testFileUrl("works21.qml"));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("value").toInt(),123);
delete object;
}
示例8: implicitQmldir
void tst_qdeclarativemoduleplugin::implicitQmldir()
{
QFETCH(QString, directory);
QFETCH(QString, file);
QFETCH(QString, errorFile);
QString importPath = QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("data") + QDir::separator() + directory;
QString fileName = QLatin1String("data") + QDir::separator() + directory + QDir::separator() + file;
QString errorFileName = directory + QDir::separator() + errorFile;
QUrl testFileUrl = TEST_FILE(fileName);
QDeclarativeEngine engine;
engine.addImportPath(importPath);
QDeclarativeComponent component(&engine, testFileUrl);
QList<QDeclarativeError> errors = component.errors();
VERIFY_ERRORS(errorFileName.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
QObject *obj = component.create();
QVERIFY(!obj);
delete obj;
}
示例9: remoteImportWithUnquotedUri
void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri()
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.serveDirectory(SRCDIR "/imports");
QDeclarativeEngine engine;
engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
QDeclarativeComponent component(&engine);
component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("width").toInt(), 300);
delete object;
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
}
示例10: importPluginWithQmlFile
void tst_qdeclarativemoduleplugin::importPluginWithQmlFile()
{
QString path = QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports");
// QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
// (this only happens if the plugin includes pure QML files)
#ifdef Q_OS_WIN
QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
path = path.at(0).toLower() + path.mid(1);
#endif
QDeclarativeEngine engine;
engine.addImportPath(path);
QDeclarativeComponent component(&engine, TEST_FILE("data/pluginWithQmlFile.qml"));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
}
示例11: incorrectPluginCase
void tst_qdeclarativemoduleplugin::incorrectPluginCase()
{
QDeclarativeEngine engine;
engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports"));
QDeclarativeComponent component(&engine, TEST_FILE("data/incorrectCase.qml"));
QList<QDeclarativeError> errors = component.errors();
QCOMPARE(errors.count(), 1);
#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
#if defined(Q_OS_MAC)
QString libname = "libPluGin.dylib";
#elif defined(Q_OS_WIN32)
QString libname = "PluGin.dll";
#endif
QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/" + libname) + QLatin1String("\"");
#else
QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
#endif
QCOMPARE(errors.at(0).description(), expectedError);
}