本文整理汇总了C++中QDeclarativeError::description方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeError::description方法的具体用法?C++ QDeclarativeError::description怎么用?C++ QDeclarativeError::description使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeError
的用法示例。
在下文中一共展示了QDeclarativeError::description方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
void tst_qdeclarativeerror::copy()
{
QDeclarativeError error;
error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
error.setDescription("An Error");
error.setLine(92);
error.setColumn(13);
QDeclarativeError error2(error);
QDeclarativeError error3;
error3 = error;
error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
error.setDescription("Another Error");
error.setLine(2);
error.setColumn(33);
QCOMPARE(error.url(), QUrl("http://www.qt-project.org/main.qml"));
QCOMPARE(error.description(), QString("Another Error"));
QCOMPARE(error.line(), 2);
QCOMPARE(error.column(), 33);
QCOMPARE(error2.url(), QUrl("http://www.qt-project.org/main.qml"));
QCOMPARE(error2.description(), QString("An Error"));
QCOMPARE(error2.line(), 92);
QCOMPARE(error2.column(), 13);
QCOMPARE(error3.url(), QUrl("http://www.qt-project.org/main.qml"));
QCOMPARE(error3.description(), QString("An Error"));
QCOMPARE(error3.line(), 92);
QCOMPARE(error3.column(), 13);
}
示例2: description
void tst_qdeclarativeerror::description()
{
QDeclarativeError error;
QCOMPARE(error.description(), QString());
error.setDescription("An Error");
QCOMPARE(error.description(), QString("An Error"));
QDeclarativeError error2 = error;
QCOMPARE(error2.description(), QString("An Error"));
error.setDescription("Another Error");
QCOMPARE(error.description(), QString("Another Error"));
QCOMPARE(error2.description(), QString("An Error"));
}
示例3: importExtension
bool QDeclarativeImportsPrivate::importExtension(const QString &absoluteFilePath, const QString &uri,
QDeclarativeImportDatabase *database,
QDeclarativeDirComponents* components, QList<QDeclarativeError> *errors)
{
QFile file(absoluteFilePath);
QString filecontent;
if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) {
if (errors) {
QDeclarativeError error;
error.setDescription(QDeclarativeImportDatabase::tr("cannot load module \"%1\": File name case mismatch for \"%2\"").arg(uri).arg(absoluteFilePath));
errors->prepend(error);
}
return false;
} else if (file.open(QFile::ReadOnly)) {
filecontent = QString::fromUtf8(file.readAll());
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeImports(" << qPrintable(base.toString()) << "::importExtension: "
<< "loaded " << absoluteFilePath;
} else {
if (errors) {
QDeclarativeError error;
error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" definition \"%2\" not readable").arg(uri).arg(absoluteFilePath));
errors->prepend(error);
}
return false;
}
QDir dir = QFileInfo(file).dir();
QUrl url = QUrl::fromLocalFile(absoluteFilePath);
QDeclarativeDirParser qmldirParser;
qmldirParser.setSource(filecontent);
qmldirParser.setUrl(url);
// propagate any errors reported by the parser back up to the typeloader.
if (qmldirParser.parse()) {
if (errors) {
for (int i = 0; i < qmldirParser.errors().size(); ++i) {
errors->prepend(qmldirParser.errors().at(i));
}
}
return false;
}
if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
QString resolvedFilePath = database->resolvePlugin(dir, plugin.path, plugin.name);
#if defined(QT_LIBINFIX) && defined(Q_OS_SYMBIAN)
if (resolvedFilePath.isEmpty()) {
// In case of libinfixed build, attempt to load libinfixed version, too.
QString infixedPluginName = plugin.name + QLatin1String(QT_LIBINFIX);
resolvedFilePath = database->resolvePlugin(dir, plugin.path, infixedPluginName);
}
#endif
if (!resolvedFilePath.isEmpty()) {
if (!database->importPlugin(resolvedFilePath, uri, errors)) {
if (errors) {
// XXX TODO: should we leave the import plugin error alone?
// Here, we pop it off the top and coalesce it into this error's message.
// The reason is that the lower level may add url and line/column numbering information.
QDeclarativeError poppedError = errors->takeFirst();
QDeclarativeError error;
error.setDescription(QDeclarativeImportDatabase::tr("plugin cannot be loaded for module \"%1\": %2").arg(uri).arg(poppedError.description()));
error.setUrl(url);
errors->prepend(error);
}
return false;
}
} else {
if (errors) {
QDeclarativeError error;
error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" plugin \"%2\" not found").arg(uri).arg(plugin.name));
error.setUrl(url);
errors->prepend(error);
}
return false;
}
}
}