[Qt-qml] Add item to a child

Tibo W tibo_wcc at yahoo.com
Fri May 27 02:02:37 CEST 2011


Hi,

by following the online doc, I can add a QML item to the top item:

QGraphicsScene *scene = declarativeView->scene();
QDeclarativeEngine *engine = declarativeView->engine();
QDeclarativeComponent component(engine, QUrl::fromLocalFile("file.qml"));
QGraphicsObject *object = qobject_cast<QGraphicsObject *>(component.create());
scene->addItem(object);

Now, I'd like to add an item to a child.
I can find the QML child by doing that:

QObject *root = declarativeView->rootObject();
QGraphicsObject *child = root->findChild<QGraphicsObject *>("childItem");

But I can't add an item to it. I tried setParent() etc. but it's not working.
I feel I'm missing something obvious...

Thanks for your help !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110526/5773734f/attachment.html 


More information about the Qt-qml mailing list