qt - QML: Component vs Item as a container -


what difference between component , item in qml ? documentation not absolutely clear here. preferred type use container several widgets? can replacable rectangle?

for example, difference in following declarations:

item {     id: itemwidget      rectangle { id: 1 }     rectangle { id: 2 } } 

and

component {     id: componentwidget      rectangle { id: 1 }     rectangle { id: 2 } } 

why use component when declaring delegate?

the difference between 2 snippets rectangle displayed. written in documentation:

notice while rectangle automatically rendered , displayed, not case above rectangle because defined inside component. component encapsulates qml types within, if defined in separate qml file, , not loaded until requested (in case, 2 loader objects). because component not derived item, cannot anchor it.

when declaring delegates, component used because there several delegate items must created. single item doesn't work here. can think of component template can create objects from.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -