Esempio n. 1
0
void contextGetProperty(QQmlContext_ *context, QString_ *name, DataValue *result)
{
    QQmlContext *qcontext = reinterpret_cast<QQmlContext *>(context);
    const QString *qname = reinterpret_cast<QString *>(name);

    QVariant var = qcontext->contextProperty(*qname);
    packDataValue(&var, result);
}
Esempio n. 2
0
/*!
  \brief QEngineMonitor::grabFromContext
  \a item
  \a contextProperty

  Returns the engine monitor located within the items context.
 */
QEngineMonitor *QEngineMonitor::grabFromContext(QQuickItem *item, const QString &contextProperty){
    QQmlContext* ctx = qmlContext(item);
    if ( ctx == 0 ){
        qWarning("Context is not yet available. Call this method outside the constructor of your current object.");
        return 0;
    }
    return static_cast<QEngineMonitor*>(ctx->contextProperty(contextProperty).value<QObject*>());
}