Context of a QDeclarativeItem



  • Hi! Is it possible to get the context that corresponds to a custom QDeclarativeItem that was instantiated in QML? I mean, something like:

    foo.qml:

    @Item {
    Component.onCompleted: component.createChildren()

    MyComponent {
    id: component
    delegate: Rectangle {}
    }@

    mycomponent.h:

    @class MyComponent : public QDeclarativeItem
    {
    ...
    Q_PROPERTY(QDeclarativeComponent* delegate ... )

    Q_INVOKABLE void createChildren()
    {
          QObject *object = delegate->create(context);  // where do I get the context from?
    }
    

    };@



  • [quote author="YetAnotherNick" date="1296247560"]Hi! Is it possible to get the context that corresponds to a custom QDeclarativeItem that was instantiated in QML?
    [/quote]

    Yes, QDeclarativeEngine::contextForObject() returns the context of an object.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.