[Interest] Problem with Loader loaded items showing
Jérôme Godbout
jerome at bodycad.com
Thu Jun 30 15:17:14 CEST 2016
I think it's related to the value assigned after the Component is created.
The behavior kick in before the initial -width is assigned. This is because
the width is not computed before teh widget is rendered and width is known.
There's a few thing to try:
1- You may try to set Behavior enabled: false upon creation, then on your
Item Component.onCompleted: myBehavior.enabled: true
I'm not sure it will solve your problems but may worth the try, will not
change the thing from happenning but could make it super fast you don't see
it.
2- Init and then create the bindng onCompleted (it will be nasty if this
component is used into other context where x can be set outside).
Item
{
x: -10000
Component.onCompleted: x = Qt.binding(function(){ return -menu.width; });
}
3- You can also try to use Loader.setSource(url source, object properties)
call instead to initialize the Component with wanted value:
Loader
{
id: loader_
property string srcFilename: "MyPathToFile.qml"
onSrcFilenameChanged: updateSourceAndBinding()
Component.onCompleted: updateSourceAndBinding()
function updateSourceAndBinding()
{
loader_.setSource(srcFilename, {'x': -10000 });
}
onLoaded:
{
item.x = Qt.binding(function(){ return -item.width; });
}
}
On Wed, Jun 29, 2016 at 1:04 PM, Dmitry Volosnykh <
dmitry.volosnykh at gmail.com> wrote:
> Hi, Jason,
> you'd better provide complete example of your issue. Anyway, Loader is an
> Item itself. Have you positioned it accordingly?
>
> On Wed, Jun 29, 2016 at 6:44 PM Jason H <jhihn at gmx.com> wrote:
>
>> I had a working app with a menu that slides in.
>> I converted it to use a Loader to load the area that contains the menu
>> and the start page. Now the menu shows up when the app first starts.
>>
>> Despite my Menu.qml being:
>> Item {
>> id: menu
>> x: -width //I should be off-screen!
>> visible: false // you're not visible!!!
>> Behavior on x {
>> NumberAnimation {
>> duration: 250
>> }
>> }
>> ...
>> }
>>
>> qml: loaderState 1
>> qml: menu.width 480
>> qml: menu.x -480
>> qml: root.onCompeleted
>>
>> It shows and slides to the left. If I comment out the behavior, it works
>> fine. I'm not sure why it's starting at X position 0, when it didn't
>> before. It doesn't look like it is being assigned to zero anywhere in
>> initialization.
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160630/9dd1eca5/attachment.html>
More information about the Interest
mailing list