[SOLVED]add child to a QQuickItem
-
Hello,
I want to add some child objects to a custom QQuickItem Plugin in c++.for this I add the objects in the constructor of the parent QQUickItem:
@overlay.setParent(this);
view.setParent(this);
overlay.setPosition(QPointF(0,0));
view.setPosition(QPointF(0,0));this->overlay.setX(0);
this->overlay.setY(0);
this->overlay.setWidth(this->width());
this->overlay.setHeight(this->height());this->view.setX(0);
this->view.setY(0);
this->view.setWidth(this->width());
this->view.setHeight(this->height());
setFlag(ItemHasContents, true);@In QML I only add the parent class with a width and a height.
Why my child objects are not visible?
Greetings
-
Hmmm i mean the problem here is width and height is not set in the constructor. You can try to override the onComplete function or set the dimensions of the child element in updatePaintNode. For performance reason maybe store the size in a property and set the new height and width only if it's changed.
-
thank you, override the onComplete method works for me