[Interest] Why wrap Rectangle/Image with Item

Sean Harmer sean.harmer at kdab.com
Sun Jan 18 13:11:43 CET 2015


On Sunday 18 January 2015 13:22:28 Sadika Sumanapala wrote:
> Hi,
> 
> What is the advantage of wrapping Rectangle/Image QML types with Item type.
> I came across several wrapping when following  QML Advanced Tutorial (
> http://doc.qt.io/qt-5/qtquick-tutorials-samegame-samegame1-example.html)
> 
> For example:
> 
> Item {
>     id: block
>     Image {
>         id: img
>         anchors.fill: parent
>         source: "../shared/pics/redStone.png"
>     }
> }
> 

In that case, one advantage is that it stops users of your custom QML element 
from changing properties that are internal. The source property, for example, 
in this case makes little sense to expose to the outside world.

Cheers,

Sean
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions



More information about the Interest mailing list