[Qt-qml] Add item to a child

Pekka.E.Jokela at nokia.com Pekka.E.Jokela at nokia.com
Fri May 27 08:38:28 CEST 2011


How about setParentItem() ?

From: qt-qml-bounces+pekka.e.jokela=nokia.com at qt.nokia.com [mailto:qt-qml-bounces+pekka.e.jokela=nokia.com at qt.nokia.com] On Behalf Of ext Tibo W
Sent: 27.05.2011 03:03
To: qt-qml at qt.nokia.com
Subject: [Qt-qml] Add item to a child

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/20110527/3f2b9c8f/attachment-0001.html 


More information about the Qt-qml mailing list