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


C++ qmlEngine函数代码示例

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


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

示例1: Q_Q

void QDeclarativeLoaderPrivate::_q_sourceLoaded()
{
    Q_Q(QDeclarativeLoader);

    if (component) {
        if (!component->errors().isEmpty()) {
            QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors());
            emit q->sourceChanged();
            emit q->statusChanged();
            emit q->progressChanged();
            return;
        }

        QDeclarativeContext *creationContext = component->creationContext();
        if (!creationContext) creationContext = qmlContext(q);
        QDeclarativeContext *ctxt = new QDeclarativeContext(creationContext);
        ctxt->setContextObject(q);

        QDeclarativeGuard<QDeclarativeComponent> c = component;
        QObject *obj = component->beginCreate(ctxt);
        if (component != c) {
            // component->create could trigger a change in source that causes
            // component to be set to something else. In that case we just
            // need to cleanup.
            if (c)
                c->completeCreate();
            delete obj;
            delete ctxt;
            return;
        }
        if (obj) {
            item = qobject_cast<QGraphicsObject *>(obj);
            if (item) {
                QDeclarative_setParent_noEvent(ctxt, obj);
                QDeclarative_setParent_noEvent(item, q);
                item->setParentItem(q);
//                item->setFocus(true);
                initResize();
            } else {
                qmlInfo(q) << QDeclarativeLoader::tr("Loader does not support loading non-visual elements.");
                delete obj;
                delete ctxt;
            }
        } else {
            if (!component->errors().isEmpty())
                QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors());
            delete obj;
            delete ctxt;
            source = QUrl();
        }
        component->completeCreate();
        emit q->sourceChanged();
        emit q->statusChanged();
        emit q->progressChanged();
        emit q->itemChanged();
        emit q->loaded();
    }
}
开发者ID:wpbest,项目名称:copperspice,代码行数:58,代码来源:qdeclarativeloader.cpp

示例2: qmlEngine

void QQuickSprite::startImageLoading()
{
    m_pix.clear(this);
    if (!m_source.isEmpty()) {
        QQmlEngine *e = qmlEngine(this);
        if (!e) { //If not created in QML, you must set the QObject parent to the QML element so this can work
            e = qmlEngine(parent());
            if (!e)
                qWarning() << "QQuickSprite: Cannot find QQmlEngine - this class is only for use in QML and may not work";
        }
        m_pix.load(e, m_source);
    }
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:13,代码来源:qquicksprite.cpp

示例3: 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;
    }
}
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:60,代码来源:qdeclarativeinfo.cpp

示例4: QPointF

QQuickItem *GlobalFunctions::itemAt(QQuickItem* parent, int x, int y, QJSValue matcher)
{
    if (!parent) return nullptr;
    QList<QQuickItem *> children = QQuickItemPrivate::get(parent)->paintOrderChildItems();

    for (int i = children.count() - 1; i >= 0; --i) {
        QQuickItem *child = children.at(i);

        // Map coordinates to the child element's coordinate space
        QPointF point = parent->mapToItem(child, QPointF(x, y));
        if (child->isVisible() && point.x() >= 0
                && child->width() >= point.x()
                && point.y() >= 0
                && child->height() >= point.y()) {
            if (!matcher.isCallable()) return child;

            QQmlEngine* engine = qmlEngine(child);
            if (!engine) return child;

            QJSValue newObj = engine->newQObject(child);
            if (matcher.call(QJSValueList() << newObj).toBool()) {
                return child;
            }
        }
    }
    return nullptr;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:27,代码来源:globalfunctions.cpp

示例5: Q_Q

void QQuickLoaderPrivate::incubatorStateChanged(QQmlIncubator::Status status)
{
    Q_Q(QQuickLoader);
    if (status == QQmlIncubator::Loading || status == QQmlIncubator::Null)
        return;

    if (status == QQmlIncubator::Ready) {
        object = incubator->object();
        item = qmlobject_cast<QQuickItem*>(object);
        emit q->itemChanged();
        initResize();
        incubator->clear();
    } else if (status == QQmlIncubator::Error) {
        if (!incubator->errors().isEmpty())
            QQmlEnginePrivate::warning(qmlEngine(q), incubator->errors());
        delete itemContext;
        itemContext = 0;
        delete incubator->object();
        source = QUrl();
        emit q->itemChanged();
    }
    if (loadingFromSource)
        emit q->sourceChanged();
    else
        emit q->sourceComponentChanged();
    emit q->statusChanged();
    emit q->progressChanged();
    if (status == QQmlIncubator::Ready)
        emit q->loaded();
    disposeInitialPropertyValues(); // cleanup
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:31,代码来源:qquickloader.cpp

示例6: qmlEngine

void Quick3DBuffer::initEngines()
{
    if (m_engine == Q_NULLPTR) {
        m_engine = qmlEngine(parent());
        m_v4engine = QQmlEnginePrivate::getV4Engine(m_engine);
    }
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:7,代码来源:quick3dbuffer.cpp

示例7: Q_D

void QDeclarativeFontLoader::setSource(const QUrl &url)
{
    Q_D(QDeclarativeFontLoader);
    if (url == d->url)
        return;
    d->url = qmlContext(this)->resolvedUrl(url);

    d->status = Loading;
    emit statusChanged();
    emit sourceChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
    QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url);
    if (!lf.isEmpty()) {
        int id = QFontDatabase::addApplicationFont(lf);
        if (id != -1) {
            d->name = QFontDatabase::applicationFontFamilies(id).at(0);
            emit nameChanged();
            d->status = QDeclarativeFontLoader::Ready;
        } else {
            d->status = QDeclarativeFontLoader::Error;
            qmlInfo(this) << "Cannot load font: \"" << url.toString() << "\"";
        }
        emit statusChanged();
    } else
#endif
    {
        QNetworkRequest req(d->url);
        req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
        d->reply = qmlEngine(this)->networkAccessManager()->get(req);
        QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(replyFinished()));
    }
}
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:32,代码来源:qdeclarativefontloader.cpp

示例8: Q_D

void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledImage& sci)
{
    Q_D(QDeclarativeBorderImage);
    if (!sci.isValid()) {
        d->status = Error;
        emit statusChanged(d->status);
    } else {
        QDeclarativeScaleGrid *sg = border();
        sg->setTop(sci.gridTop());
        sg->setBottom(sci.gridBottom());
        sg->setLeft(sci.gridLeft());
        sg->setRight(sci.gridRight());
        d->horizontalTileMode = sci.horizontalTileRule();
        d->verticalTileMode = sci.verticalTileRule();

        d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));

        QDeclarativePixmap::Options options;
        if (d->async)
            options |= QDeclarativePixmap::Asynchronous;
        if (d->cache)
            options |= QDeclarativePixmap::Cache;
        d->pix.clear(this);
        d->pix.load(qmlEngine(this), d->sciurl, options);

        if (d->pix.isLoading()) {
            static int thisRequestProgress = -1;
            static int thisRequestFinished = -1;
            if (thisRequestProgress == -1) {
                thisRequestProgress =
                    QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
                thisRequestFinished =
                    QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestFinished()");
            }

            d->pix.connectFinished(this, thisRequestFinished);
            d->pix.connectDownloadProgress(this, thisRequestProgress);

        } else {

            QSize impsize = d->pix.implicitSize();
            setImplicitWidth(impsize.width());
            setImplicitHeight(impsize.height());

            if (d->pix.isReady()) {
                d->status = Ready;
            } else {
                d->status = Error;
                qmlInfo(this) << d->pix.error();
            }

            d->progress = 1.0;
            emit statusChanged(d->status);
            emit progressChanged(1.0);
            update();

        }
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:59,代码来源:qdeclarativeborderimage.cpp

示例9: Q_Q

void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
    Q_Q(QQuickWebEngineView);
    QJSValue callback = m_callbacks.take(requestId);
    QJSValueList args;
    args.append(qmlEngine(q)->toScriptValue(result));
    callback.call(args);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:8,代码来源:qquickwebengineview.cpp

示例10: EDEBUG

void QmlCppEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
{
    EDEBUG("MASTER REMOTE SETUP FINISHED");
    DebuggerEngine::notifyEngineRemoteSetupFinished(result);

    cppEngine()->notifyEngineRemoteSetupFinished(result);
    qmlEngine()->notifyEngineRemoteSetupFinished(result);
}
开发者ID:acacid,项目名称:qt-creator,代码行数:8,代码来源:qmlcppengine.cpp

示例11: EDEBUG

void QmlCppEngine::notifyEngineRemoteSetupFailed(const QString &message)
{
    EDEBUG("MASTER REMOTE SETUP FAILED");
    DebuggerEngine::notifyEngineRemoteSetupFailed(message);

    cppEngine()->notifyEngineRemoteSetupFailed(message);
    qmlEngine()->notifyEngineRemoteSetupFailed(message);
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:8,代码来源:qmlcppengine.cpp

示例12: qmlEngine

// get all entries (this is costly call)
QJSValue ValueModel::getList() const
{
    QJSValue array = qmlEngine(this)->newArray(m_data.count());
    for(int i=0; i<m_data.count(); i++) {
        array.setProperty(i, m_data.at(i));
    }
    return array;
}
开发者ID:4lenz1,项目名称:qmlbook,代码行数:9,代码来源:valuemodel.cpp

示例13: qmlEngine

void OpdsBookModel::load(const QUrl &source)
{
    QNetworkAccessManager *manager = qmlEngine(QObject::parent())->networkAccessManager();

    QNetworkRequest request(source);
    QNetworkReply *reply = manager->get(request);
    connect(reply, &QNetworkReply::finished, this, &OpdsBookModel::onReplyFinished);
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:8,代码来源:opdsbookmodel.cpp

示例14: Q_D

void QDeclarativeAnimatedImage::setSource(const QUrl &url)
{
    Q_D(QDeclarativeAnimatedImage);
    if (url == d->url)
        return;

    delete d->_movie;
    d->_movie = 0;

    if (d->reply) {
        d->reply->deleteLater();
        d->reply = 0;
    }

    d->url = url;

    if (url.isEmpty()) {
        delete d->_movie;
        d->status = Null;
    } else {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
        QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url);
        if (!lf.isEmpty()) {
            //### should be unified with movieRequestFinished
            d->_movie = new QMovie(lf);
            if (!d->_movie->isValid()){
                qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString();
                delete d->_movie;
                d->_movie = 0;
                return;
            }
            connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
                    this, SLOT(playingStatusChanged()));
            connect(d->_movie, SIGNAL(frameChanged(int)),
                    this, SLOT(movieUpdate()));
            d->_movie->setCacheMode(QMovie::CacheAll);
            if(d->playing)
                d->_movie->start();
            else
                d->_movie->jumpToFrame(0);
            if(d->paused)
                d->_movie->setPaused(true);
            d->setPixmap(d->_movie->currentPixmap());
            d->status = Ready;
            d->progress = 1.0;
            emit statusChanged(d->status);
            emit sourceChanged(d->url);
            emit progressChanged(d->progress);
            return;
        }
#endif
        d->status = Loading;
        QNetworkRequest req(d->url);
        req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
        d->reply = qmlEngine(this)->networkAccessManager()->get(req);
        QObject::connect(d->reply, SIGNAL(finished()),
                         this, SLOT(movieRequestFinished()));
    }
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:58,代码来源:qdeclarativeanimatedimage.cpp

示例15: CompetitorDocument

QObject *CompetitorsPlugin::createCompetitorDocument(QObject *parent)
{
	CompetitorDocument *ret = new CompetitorDocument(parent);
	if(!parent) {
		qfWarning() << "Parent is NULL, created class will have QQmlEngine::JavaScriptOwnership.";
		qmlEngine()->setObjectOwnership(ret, QQmlEngine::JavaScriptOwnership);
	}
	return ret;
}
开发者ID:mezkov,项目名称:quickbox,代码行数:9,代码来源:competitorsplugin.cpp


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