[Qt-qml] Add item to a child

Tibo W tibo_wcc at yahoo.com
Fri May 27 20:00:21 CEST 2011


kiitos !


--- On Fri, 5/27/11, Pekka.E.Jokela at nokia.com <Pekka.E.Jokela at nokia.com> wrote:

From: Pekka.E.Jokela at nokia.com <Pekka.E.Jokela at nokia.com>
Subject: RE: [Qt-qml] Add item to a child
To: tibo_wcc at yahoo.com, qt-qml at qt.nokia.com
Date: Friday, May 27, 2011, 6:38 AM



 
 


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/93ba98cb/attachment.html 


More information about the Qt-qml mailing list