Why is there extra wrapping of components?
-
I see this a lot in online code - somebody needs a checkbox in a table, and they define their delegate like "matryoshkas":http://en.wikipedia.org/wiki/Matryoshka_doll:
@Component {
id: checkBoxDelegateItem { CheckBox { anchors.fill: parent checked: styleData.value } }
}
@What is the benefit of this over a more simple definition:
@CheckBox {
id: checkBoxDelegate
anchors.fill: parent
checked: styleData.value
}
@And it's not just people in the interwebs, the Qt documentation does the same thing (in http://qt-project.org/doc/qt-5/qml-qtquick-controls-tableview.html )
@
itemDelegate: Item {
Text {
anchors.verticalCenter: parent.verticalCenter
color: styleData.textColor
elide: styleData.elideMode
text: styleData.value
}
}
@Why the extra layer of "Item" there? Why not just:
@
itemDelegate: Text {
anchors.verticalCenter: parent.verticalCenter
color: styleData.textColor
elide: styleData.elideMode
text: styleData.value
}
@Thanks,
Chris