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


C++ QQmlError::setUrl方法代码示例

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


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

示例1: copy

void tst_qqmlerror::copy()
{
    QQmlError error;
    error.setUrl(QUrl("http://www.qt-project.org/main.qml"));
    error.setDescription("An Error");
    error.setLine(92);
    error.setColumn(13);

    QQmlError error2(error);
    QQmlError 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);

}
开发者ID:mortenelund,项目名称:qt,代码行数:33,代码来源:tst_qqmlerror.cpp

示例2: qmlBinding

QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, QObject *qmlScope,
                                                       const QString &code, const QString &filename, quint16 line,
                                                       QV4::PersistentValue *qmlscope)
{
    QQmlEngine *engine = ctxt->engine;
    QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);

    QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
    QV4::ExecutionContext *ctx = v4->currentContext();
    QV4::Scope scope(v4);

    QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, qmlScope));
    QV4::Script script(v4, qmlScopeObject, code, filename, line);
    QV4::ScopedValue result(scope);
    script.parse();
    if (!v4->hasException)
        result = script.qmlBinding();
    if (v4->hasException) {
        QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
        if (error.description().isEmpty())
            error.setDescription(QLatin1String("Exception occurred during function evaluation"));
        if (error.line() == -1)
            error.setLine(line);
        if (error.url().isEmpty())
            error.setUrl(QUrl::fromLocalFile(filename));
        error.setObject(qmlScope);
        ep->warning(error);
        return QV4::Encode::undefined();
    }
    if (qmlscope)
        *qmlscope = qmlScopeObject;
    return result.asReturnedValue();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:33,代码来源:qqmljavascriptexpression.cpp

示例3: lexer

CompiledData::CompilationUnit *Script::precompile(ExecutionEngine *engine, const QUrl &url, const QString &source, QList<QQmlError> *reportedErrors)
{
    using namespace QQmlJS;
    using namespace QQmlJS::AST;

    QQmlJS::V4IR::Module module(engine->debugger != 0);

    QQmlJS::Engine ee;
    QQmlJS::Lexer lexer(&ee);
    lexer.setCode(source, /*line*/1, /*qml mode*/true);
    QQmlJS::Parser parser(&ee);

    parser.parseProgram();

    QList<QQmlError> errors;

    foreach (const QQmlJS::DiagnosticMessage &m, parser.diagnosticMessages()) {
        if (m.isWarning()) {
            qWarning("%s:%d : %s", qPrintable(url.toString()), m.loc.startLine, qPrintable(m.message));
            continue;
        }

        QQmlError error;
        error.setUrl(url);
        error.setDescription(m.message);
        error.setLine(m.loc.startLine);
        error.setColumn(m.loc.startColumn);
        errors << error;
    }

    if (!errors.isEmpty()) {
        if (reportedErrors)
            *reportedErrors << errors;
        return 0;
    }

    Program *program = AST::cast<Program *>(parser.rootNode());
    if (!program) {
        // if parsing was successful, and we have no program, then
        // we're done...:
        return 0;
    }

    QQmlJS::Codegen cg(/*strict mode*/false);
    cg.generateFromProgram(url.toString(), source, program, &module, QQmlJS::Codegen::EvalCode);
    errors = cg.errors();
    if (!errors.isEmpty()) {
        if (reportedErrors)
            *reportedErrors << cg.errors();
        return 0;
    }

    Compiler::JSUnitGenerator jsGenerator(&module);
    QScopedPointer<QQmlJS::EvalInstructionSelection> isel(engine->iselFactory->create(QQmlEnginePrivate::get(engine), engine->executableAllocator, &module, &jsGenerator));
    isel->setUseFastLookups(false);
    return isel->compile();
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:57,代码来源:qv4script.cpp

示例4: recordError

void QmcTypeCompiler::recordError(const QV4::CompiledData::Location& location, const QString& description)
{
    QQmlError error;
    error.setLine(location.line);
    error.setColumn(location.column);
    error.setUrl(compiledData->url);
    error.setDescription(description);
    recordError(error);
}
开发者ID:toby20130333,项目名称:qmlc,代码行数:9,代码来源:qmctypecompiler.cpp

示例5: url

void tst_qqmlerror::url()
{
    QQmlError error;

    QCOMPARE(error.url(), QUrl());

    error.setUrl(QUrl("http://www.qt-project.org/main.qml"));

    QCOMPARE(error.url(), QUrl("http://www.qt-project.org/main.qml"));

    QQmlError error2 = error;

    QCOMPARE(error2.url(), QUrl("http://www.qt-project.org/main.qml"));

    error.setUrl(QUrl("http://www.qt-project.org/main.qml"));

    QCOMPARE(error.url(), QUrl("http://www.qt-project.org/main.qml"));
    QCOMPARE(error2.url(), QUrl("http://www.qt-project.org/main.qml"));
}
开发者ID:mortenelund,项目名称:qt,代码行数:19,代码来源:tst_qqmlerror.cpp

示例6: debug

void tst_qqmlerror::debug()
{
    {
        QQmlError 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(dataDirectoryUrl().resolved(QUrl("test.txt")));
        QQmlError 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(dataDirectoryUrl().resolved(QUrl("foo.txt")));
        QQmlError 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;
    }
}
开发者ID:mortenelund,项目名称:qt,代码行数:41,代码来源:tst_qqmlerror.cpp

示例7: ctxtscope

// Callee owns the persistent handle
v8::Persistent<v8::Function>
QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
                                       const char *code, int codeLength,
                                       const QString &filename, quint16 line,
                                       v8::Persistent<v8::Object> *qmlscope)
{
    QQmlEngine *engine = ctxt->engine;
    QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);

    v8::HandleScope handle_scope;
    v8::Context::Scope ctxtscope(ep->v8engine()->context());

    v8::TryCatch tc;
    v8::Local<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
    v8::Local<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line);
    if (tc.HasCaught()) {
        QQmlError error;
        error.setDescription(QLatin1String("Exception occurred during function compilation"));
        error.setLine(line);
        error.setUrl(QUrl::fromLocalFile(filename));
        v8::Local<v8::Message> message = tc.Message();
        if (!message.IsEmpty())
            QQmlExpressionPrivate::exceptionToError(message, error);
        ep->warning(error);
        return v8::Persistent<v8::Function>();
    }
    v8::Local<v8::Value> result = script->Run(scopeobject);
    if (tc.HasCaught()) {
        QQmlError error;
        error.setDescription(QLatin1String("Exception occurred during function evaluation"));
        error.setLine(line);
        error.setUrl(QUrl::fromLocalFile(filename));
        v8::Local<v8::Message> message = tc.Message();
        if (!message.IsEmpty())
            QQmlExpressionPrivate::exceptionToError(message, error);
        ep->warning(error);
        return v8::Persistent<v8::Function>();
    }
    if (qmlscope) *qmlscope = qPersistentNew<v8::Object>(scopeobject);
    return qPersistentNew<v8::Function>(v8::Local<v8::Function>::Cast(result));
}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:42,代码来源:qqmljavascriptexpression.cpp

示例8: toString

void tst_qqmlerror::toString()
{
    {
        QQmlError 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"));
    }

    {
        QQmlError 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"));
    }
}
开发者ID:mortenelund,项目名称:qt,代码行数:21,代码来源:tst_qqmlerror.cpp

示例9: exceptionToError

void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message, QQmlError &error)
{
    Q_ASSERT(!message.IsEmpty());

    v8::Handle<v8::Value> name = message->GetScriptResourceName();
    v8::Handle<v8::String> description = message->Get();
    int lineNumber = message->GetLineNumber();

    v8::Local<v8::String> file = name->IsString()?name->ToString():v8::Local<v8::String>();
    if (file.IsEmpty() || file->Length() == 0)
        error.setUrl(QUrl());
    else
        error.setUrl(QUrl(QV8Engine::toStringStatic(file)));

    error.setLine(lineNumber);
    error.setColumn(-1);

    QString qDescription = QV8Engine::toStringStatic(description);
    if (qDescription.startsWith(QLatin1String("Uncaught ")))
        qDescription = qDescription.mid(9 /* strlen("Uncaught ") */);

    error.setDescription(qDescription);
}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:23,代码来源:qqmljavascriptexpression.cpp

示例10: url

QList<QQmlError> QQmlDirParser::errors(const QString &uri) const
{
    QUrl url(uri);
    QList<QQmlError> errors;
    for (int i = 0; i < _errors.size(); ++i) {
        const QQmlJS::DiagnosticMessage &msg = _errors.at(i);
        QQmlError e;
        QString description = msg.message;
        description.replace(QLatin1String("$$URI$$"), uri);
        e.setDescription(description);
        e.setUrl(url);
        e.setLine(msg.loc.startLine);
        e.setColumn(msg.loc.startColumn);
        errors << e;
    }
    return errors;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:qqmldirparser.cpp

示例11: compile

bool Compiler::compile(const QString &url, const QString &outputFile)
{
    // open output file
    QFile f(outputFile);
    if (!f.open(QFile::WriteOnly | QFile::Truncate)) {
        QQmlError error;
        error.setDescription("Could not open file for writing");
        error.setUrl(QUrl(outputFile));
        return false;
    }
    QDataStream out(&f);

    bool ret = compile(url, out);
    f.close();

    return ret;
}
开发者ID:niqt,项目名称:qmlc,代码行数:17,代码来源:compiler.cpp

示例12: setWindowVisibility

void QQuickWindowQmlImpl::setWindowVisibility()
{
    Q_D(QQuickWindowQmlImpl);
    if (transientParent() && !transientParent()->isVisible())
        return;

    if (sender()) {
        disconnect(transientParent(), &QWindow::visibleChanged, this,
                   &QQuickWindowQmlImpl::setWindowVisibility);
    }

    // We have deferred window creation until we have the full picture of what
    // the user wanted in terms of window state, geometry, visibility, etc.

    if ((d->visibility == Hidden && d->visible) || (d->visibility > AutomaticVisibility && !d->visible)) {
        QQmlData *data = QQmlData::get(this);
        Q_ASSERT(data && data->context);

        QQmlError error;
        error.setObject(this);

        const QQmlContextData* urlContext = data->context;
        while (urlContext && urlContext->url().isEmpty())
            urlContext = urlContext->parent;
        error.setUrl(urlContext ? urlContext->url() : QUrl());

        QString objectId = data->context->findObjectId(this);
        if (!objectId.isEmpty())
            error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl",
                "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId));
        else
            error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl",
                "Conflicting properties 'visible' and 'visibility'"));

        QQmlEnginePrivate::get(data->context->engine)->warning(error);
    }

    if (d->visibility == AutomaticVisibility) {
        setWindowState(QGuiApplicationPrivate::platformIntegration()->defaultWindowState(flags()));
        setVisible(d->visible);
    } else {
        setVisibility(d->visibility);
    }
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:44,代码来源:qquickwindowmodule.cpp

示例13: loadData

bool Compiler::loadData()
{
    Q_D(Compiler);
    const QUrl& url = d->compilation->loadUrl;
    if (!url.isValid() || url.isEmpty())
        return false;
    QQmlFile f;
    f.load(d->compilation->engine, url);
    if (!f.isReady()) {
        if (f.isError()) {
            QQmlError error;
            error.setUrl(url);
            error.setDescription(f.error());
            appendError(error);
        }
        return false;
    }
    d->compilation->code = QString::fromUtf8(f.data());
    return true;
}
开发者ID:niqt,项目名称:qmlc,代码行数:20,代码来源:compiler.cpp

示例14: exportData

bool Compiler::exportData(QDataStream &output)
{
    Q_D(Compiler);

    QQmlError error;
    if (!d->compilation->checkData(error)) {
        error.setUrl(d->compilation->url);
        appendError(error);
        return false;
    }

    QmcExporter exporter(d->compilation);
    bool ret = exporter.exportQmc(output);
    if (!ret) {
        QQmlError error;
        error.setDescription("Error saving data");
        appendError(error);
    }
    return ret;
}
开发者ID:RichardsATcn,项目名称:qmlc,代码行数:20,代码来源:compiler.cpp

示例15: qmlEngine

QQmlInfo::~QQmlInfo()
{
    if (0 == --d->ref) {
        QList<QQmlError> errors = d->errors;

        QQmlEngine *engine = 0;

        if (!d->buffer.isEmpty()) {
            QQmlError error;

            QObject *object = const_cast<QObject *>(d->object);

            if (object) {
                engine = qmlEngine(d->object);
                QString typeName;
                QQmlType *type = QQmlMetaType::qmlType(object->metaObject());
                if (type) {
                    typeName = 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);
                        typeName += QLatin1Char('*');
                        type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
                        if (type) {
                            typeName = type->qmlTypeName();
                            int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
                            if (lastSlash != -1)
                                typeName = typeName.mid(lastSlash+1);
                        }
                    }
                }

                d->buffer.prepend(QLatin1String("QML ") + typeName + QLatin1String(": "));

                QQmlData *ddata = QQmlData::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);
        }

        QQmlEnginePrivate::warning(engine, errors);

        delete d;
    }
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:61,代码来源:qqmlinfo.cpp


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