本文整理汇总了C++中QDeclarativeError::setLine方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeError::setLine方法的具体用法?C++ QDeclarativeError::setLine怎么用?C++ QDeclarativeError::setLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeError
的用法示例。
在下文中一共展示了QDeclarativeError::setLine方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: qmlEngine
QDeclarativeInfo::~QDeclarativeInfo()
{
if (0 == --d->ref) {
QList<QDeclarativeError> errors = d->errors;
QDeclarativeEngine *engine = 0;
if (!d->buffer.isEmpty()) {
QDeclarativeError error;
QObject *object = const_cast<QObject *>(d->object);
if (object) {
engine = qmlEngine(d->object);
QString typeName;
QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
if (type) {
typeName = QLatin1String(type->qmlTypeName());
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
} else {
typeName = QString::fromUtf8(object->metaObject()->className());
int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
if (marker != -1)
typeName = typeName.left(marker);
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
typeName = typeName.left(marker) + "*";
type = QDeclarativeMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type) {
typeName = QLatin1String(type->qmlTypeName());
int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
if (lastSlash != -1)
typeName = typeName.mid(lastSlash+1);
}
}
}
d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));
QDeclarativeData *ddata = QDeclarativeData::get(object, false);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) {
error.setUrl(ddata->outerContext->url);
error.setLine(ddata->lineNumber);
error.setColumn(ddata->columnNumber);
}
}
error.setDescription(d->buffer);
errors.prepend(error);
}
QDeclarativeEnginePrivate::warning(engine, errors);
delete d;
}
}
示例3: reportError
void QDeclarativeDirParser::reportError(int line, int column, const QString &description)
{
QDeclarativeError error;
error.setUrl(_url);
error.setLine(line);
error.setColumn(column);
error.setDescription(description);
_errors.append(error);
}
示例4: error
/*!
Reports an error in parsing \a node, with the given \a description.
An error is generated referring to the position of \a node in the source file.
*/
void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, const QString& description)
{
QDeclarativeError error;
QString exceptionDescription;
error.setLine(node.location().line);
error.setColumn(node.location().column);
error.setDescription(description);
exceptions << error;
}
示例5: line
void tst_qdeclarativeerror::line()
{
QDeclarativeError error;
QCOMPARE(error.line(), -1);
error.setLine(102);
QCOMPARE(error.line(), 102);
QDeclarativeError error2 = error;
QCOMPARE(error2.line(), 102);
error.setLine(4);
QCOMPARE(error.line(), 4);
QCOMPARE(error2.line(), 102);
}
示例6: debug
void tst_qdeclarativeerror::debug()
{
{
QDeclarativeError error;
error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
error.setDescription("An Error");
error.setLine(92);
error.setColumn(13);
QTest::ignoreMessage(QtWarningMsg, "http://www.qt-project.org/main.qml:92:13: An Error ");
qWarning() << error;
}
{
QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("test.txt")));
QDeclarativeError error;
error.setUrl(url);
error.setDescription("An Error");
error.setLine(2);
error.setColumn(5);
QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
qWarning() << error;
}
{
QUrl url(QUrl::fromLocalFile(QString(SRCDIR) + "/").resolved(QUrl("foo.txt")));
QDeclarativeError error;
error.setUrl(url);
error.setDescription("An Error");
error.setLine(2);
error.setColumn(5);
QString out = url.toString() + ":2:5: An Error ";
QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
qWarning() << error;
}
}
示例7: toString
void tst_qdeclarativeerror::toString()
{
{
QDeclarativeError error;
error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
error.setDescription("An Error");
error.setLine(92);
error.setColumn(13);
QCOMPARE(error.toString(), QString("http://www.qt-project.org/main.qml:92:13: An Error"));
}
{
QDeclarativeError error;
error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
error.setDescription("An Error");
error.setLine(92);
QCOMPARE(error.toString(), QString("http://www.qt-project.org/main.qml:92: An Error"));
}
}