[Interest] How can i animate Layout.preferredWidth and friends?

Mark markg85 at gmail.com
Fri Oct 11 17:08:00 CEST 2013


On Fri, Oct 11, 2013 at 2:37 PM, Saether Jan-Arve <
Jan-Arve.Saether at digia.com> wrote:

> > > Of course it should not crash.
> > > I get an ASSERT: "mo" in file qml\qqmlvme.cpp, line 849 (this is with
> current stable branch though).
> > >
> > > I'm a bit curious to know why do you want to animate that property?
> > > What do you want to achieve?
> > >
> > > Jan Arve
> > >
> > > From: interest-bounces+jan-arve.saether=digia.com at qt-project.org[mailto:
> interest-bounces+jan-arve.saether=digia.com at qt-project.org] On Behalf Of
> Mark
> > > > Sent: 30. september 2013 01:40
> > > > To: Qt Interest
> > > > Subject: [Interest] How can i animate Layout.preferredWidth and
> friends?
> > > >
> > > > Hi,
> > > >
> > > > I thought something as simple as:
> > > >
> > > >            Behavior on Layout.preferredWidth {
> > > >                NumberAnimation { duration: 1000 }
> > > >            }
> > > >
> > > > would do.. Apparently not since it crashes qmlscene..
> > > > Do i need to do it differently or did i just hit a bug?
> > > >
> > > > Version details:
> > > > Qt 5.1.0 x64 (i know, 5.1.1 is out)
> > > > Mac Mountain Lion fully updated
> > > >
> > > > Cheers,
> > > > Mark
> >  Hi Jan,
> >
> > What i try to do is animate the (in this case) width. In a simple
> > description that would be it. However, i try to animate the with of a
> > component that is within a Layout. In this case a RowLayout. If i use
> > the width, the RowLayout itself doesn't update, you can see that in
> > this snippet [1]. Just press the nice orange square :) What i want
> > for that is to work. I tried animating the Layout.preferredWidth
> > property because changing the width using that does update the
> > RowLayout, but then the animation doesn't work.
> >
> > That's all i'm trying to do.
> >
> > [1] http://pastebin.kde.org/pxgjxhtza
>
> Your example code works exactly how I would expect it to work.
> You are only animating the width of the red rectangle, and the layout
> doesn't rely on the width property for rearranging its items.
> Therefore, the layout and the other children are not affected by this.
> (Try to set opacity: 0.5 on the green item, then you will better see
> what's going on :-)
>

I actually didn't do that before. Tried it out just now and it indeed does
exactly what i would expect :) Only issue is that the layout itself doesn't
do what i expect..
I was about to create a bug report, but the qt-project site is currently
extremely slow with the occasional timeout errors... So i will do that
later.

>
> However, I would expect changing togglePreferredWidth to actually
> toggle Layout.preferredWidth (while keeping the Behavior on width) to
> do what you want, but I think that Behaviors are only applied if the
> property
> is changed in QML. (The width property is changed in the C++ backend of
> the layout engine, which then wouldn't apply the behavior)
>

I actually tried that initially but that didn't work.

>
> This modified example demonstrates the issue, and AFAIK it's a limitation
> of the
> Behavior element:
>
> http://pastebin.com/bcD9wRu5
>
> Jan Arve
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131011/e2c3449b/attachment.html>


More information about the Interest mailing list