Hi,

I was wondering if I am the only one who found the initial property of a
source based Loader Item a bit annoying. inline sourceComponent with
Component {} declaration are well ok on the other hand. I'm explaining
myself, when using a loader you have 2 choice to set the initial binding on
created item:

1- On item changed set the binding

*Loader*
*{*
*  source: externalObj.getSrc() // return something like "myItem.qml"*
*  onItemChanged:*
*  {*
*    if(!item) return;*
*    item.myprop = Qt.binding(function(){ return myExternalProperty; })*
*  }*
*}*

2- use the setSource() function instead of the source directly

*Loader*
*{*
*  property url myDummySrc: externalObj.getSrc()*
*  onMyDummySrcChanged:*
*  {*
*     setSource(myDummySrc, { 'myprop': Qt.binding(function(){ return
myExternalProperty; }) });*
*  }*
*}*

This is rather annoying and ugly. Number 1 is also having the problem where
*myItem.qml* must be able to handle *myprop *to have a default value or
being empty without output a lots of console error. Number 2 work well and
is the solution I find myself writing often. I was wondering if a Loader
that support a dictionary of initial property when source changed would be
nice:

*Loader*
*{*
*  source: externalObj.getSrc()*
*  initialProperties: { 'myprop': Qt.binding(function(){ return
myExternalProperty; })  }*
*}*

What do you think?
Jerome
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to