Solved Add QML component to inner component. How?
-
Hello all!
Is there any way to add QML component to inner component inside of custom component?
For example I have:- CustomComponent.qml
CustomComponent { ... Column { id: oColumn; // Add here from outside Rectangle{id: rectangle1} Rectangle{id: rectangle2} Rectangle{id: rectangle3} } }
- Main.qml
ApplicationWindow { CustomComponent { Rectangle{id: rectangle1} Rectangle{id: rectangle2} Rectangle{id: rectangle3} } }
When I am using CustomComponent {} in Main.qml and addig rectangle how to add not to CustomComponent but to Column that is inside of CustomComponent? Is there option through property o something else?
-
Set default property
contentData
:CustomComponent { ... default property alias contentData: oColumn.data Column { id: oColumn } }
-
@IntruderExcluder Thx. That's what I forgotten "default" and "data". And it's working only if there are one component to add. If there multiple to add it's not working. Only if there adding like array, something like this:
ApplicationWindow { CustomComponent { oColumn: [ Rectangle{id: rectangle1}, Rectangle{id: rectangle2}, Rectangle{id: rectangle3} ] } }
And "default" not required. Issue closed.
-
Multiple components in my case can be added as well:
ApplicationWindow { CustomComponent { Rectangle { } Rectangle { } Rectangle { } } }
-
@IntruderExcluder What if you have 2 Columns? And you need to do it for both of them?
-
I'd prefer to separate such logic into different components.