Exemple #1
0
QObject *QDeclarativeComponentPrivate::create(QDeclarativeContextData *context,
        const QBitField &bindings)
{
    if (!context)
        context = QDeclarativeContextData::get(engine->rootContext());

    QObject *rv = beginCreate(context, bindings);
    completeCreate();
    return rv;
}
/*!
    Create an object instance from this component.  Returns 0 if creation
    failed.  \a context specifies the context within which to create the object
    instance.

    If \a context is 0 (the default), it will create the instance in the
    engine' s \l {QDeclarativeEngine::rootContext()}{root context}.
*/
QObject *QDeclarativeComponent::create(QDeclarativeContext *context)
{
    Q_D(QDeclarativeComponent);

    if (!context)
        context = d->engine->rootContext();

    QObject *rv = beginCreate(context);
    completeCreate();
    return rv;
}
Exemple #3
0
QMLOutput* QMLOutputComponent::createForOutput(const KScreen::OutputPtr &output)
{
    QObject *instance;

    instance = beginCreate(m_engine->rootContext());
    if (!instance) {
        qWarning() << errorString();
        return 0;
    }

    bool success = false;
    success = instance->setProperty("outputPtr", QVariant::fromValue(output));
    Q_ASSERT(success);
    success = instance->setProperty("screen", QVariant::fromValue(qobject_cast<QMLScreen*>(parent())));
    Q_ASSERT(success);
    Q_UNUSED(success);

    completeCreate();

    return qobject_cast<QMLOutput*>(instance);
}