[Development] Comparing two reals in Qt code

Alan Alpert 416365416c at gmail.com
Sat Dec 8 18:32:17 CET 2012


That sounds more like a bug in a particular usecase than a general
problem of float rounding. If we fixed the anchors so that width
didn't change on a left/right anchored item in this circumstance,
would that be enough?

--
Alan Alpert

On Fri, Dec 7, 2012 at 8:33 AM, Dominik Holland
<dominik.holland at pelagicore.com> wrote:
> Hi,
>
> it took some time to get the code simple, but here is is a little
> example code:
>
> import QtQuick 1.0
>
> Rectangle {
>      id: root
>      width: 360
>      height: 360
>
>      Item {
>          id: item
>
>          width: 50
>          height: 50
>
>          Rectangle {
>              id: rect
>
>              anchors.top: parent.top
>              anchors.left: parent.left
>              anchors.right: parent.right
>              anchors.bottom: parent.bottom
>
>              color: "blue"
>
>              onWidthChanged: print("widthChanged " + width)
>              onHeightChanged: print("heightChanged " + height)
>          }
>      }
>
>
>      SequentialAnimation {
>          id: animation
>          loops: 200
>          NumberAnimation {
>              target: item;
>              property: 'x';
>              to: 0;
>              duration: 1000;
>              easing.type: Easing.OutCubic
>          }
>          NumberAnimation {
>              target: item;
>              property: 'x';
>              to: 300;
>              duration: 1000;
>              easing.type: Easing.OutCubic
>          }
>      }
>
>
>      MouseArea {
>          anchors.fill: parent
>
>          onClicked: {
>              print("clicked")
>              animation.restart()
>          }
>      }
> }
>
>
> The important thing here are the anchors of rect. If you set this to
> anchors.fill: parent it works as expected.
>
> Best Regards
>   Dominik
>
>
> On 12/03/2012 08:55 AM, Samuel Rødal wrote:
>> On 11/29/2012 03:01 PM, Dominik Holland wrote:
>>> Hi all,
>>>
>>> last month i had some performance problems on a QML animation running on
>>> low end hardware (imx233).
>>> I debugged that problem and it was caused because of rounding errors
>>> during the comparison of two reals.
>> What kind of QML code leads to these rounding issues? Would be useful to
>> have some examples to go from, before deciding at what level it should
>> be fixed.
>>
>> --
>> Samuel
>> _______________________________________________
>> Development mailing list
>> Development at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/development
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list