Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112230

Make QML anchors behave actually declarative.

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.4.2
    • None
    • All

    Description

      Anchors are pretty neat and they are quite flexible.

      One thing that is pretty awesome is that you can actively assign 'undefined' which makes them more powerful.

      For instance you can change the top anchor to undefined and set the verticalCenter instead at some button press.

      Where this falls down, though, is in a declarative setting.

      Take the attached example QML application (tested with 'qml6' executable).

      We have a property that changes value and the two anchors on an object:

      anchors.top: cb.checked ? undefined: parent.top
      anchors.bottom: cb.checked ? parent.verticalCenter : undefined

       

      What I expect to happen is, in detail, that the object this is set on will update those top and bottom properties by calling the C++ setters.

      Then at the end of the cb checked changed signal (or simply in a new event in the eventloop) figure out the new geometry and positioning based on the changed anchors.

       
      What is actually happening (I'm guessing, didn't look at the code), is that the top and bottom properties are set individually one after the other. And they protect against internal state inconsistencies and thus they reject some changes or make adjustments to height instead.

      The result is very non-intuitive and basically means you can't use constructions like the above if you actually expect the property to be changed during the lifetime of the object you are anchoring.

      It would likely work if you use this in a procedural manner. A 'onCheckedChange' that first sets the one to undefined and then the other to the new value.

      Please consider re-architecting the anchors stuff to make it possible to use them more declaratively.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tomz Tom Zander
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes