Hi,
AFAIK, you should use setParentItem [qt-project.org] to set parent for the QQuickItem that you create and not to the component.
Also Component.onCompleted is called as soon as you create the component using create().
Instead use beginCreate [qt-project.org] and then set properties what ever you wish to and at the end call completeCreate [qt-project.org]. This will ensure that parentItem has been set to the Item before the Component is Completed.
So to sum up,
1. Create QQmlComponent object
2. Use beginCreate() to create object instead of create()
3. Cast created object to QQuickItem
4. Set QQuickItem’s setParentItem
5. Set QQuickItem’s properties if any
6. Call completeCreate()
Hope this helps…
↧