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

GridLayout does not work with computed child width/height

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.8.0, 5.9.0 RC, 5.9.1, 5.11.0
    • Quick: Layouts
    • None
    • Linux yoga 4.7.6-1-ARCH #1 SMP PREEMPT Fri Sep 30 19:28:42 CEST 2016 x86_64 GNU/Linux

    Description

      Testcase:

      import QtQuick 2.2
      import QtQuick.Layouts 1.3
      
      GridLayout {
        columns: 3
        Repeater {
          model: 5
          Component.onCompleted: model = 6
          Rectangle {
            width: 50 + 0
            height: 50 + 0
            opacity: 0.5
            color: 'red'
            Text {
              text: index
            }
          }
        }
      }
      

      Note that changing width/height individually to just `50` produces different invalid results, but changing them both to just `50` produces expected result.

      `model = 6` updates the items count. It doesn't necesarry have to increase the number of elements by 1, any change in the elements count triggers the bug here — you could verify that e.g. by setting `model = 2` there. It also doesn't have to be a number — using a ListModel and appending an element to it results in the same buggy behaviour.

      `Text` item is irrelevant to the testcase and just demonstrates invalid positioning of the elements, e.g. in the case of `width: 50; height: 50 + 0`.

      Note: while `50 + 0` is technically a static expression, it still triggers that bug, and this is thus the minimal testcase I was able to find (well, `(50)` also triggers the bug). The same issue happens, e.g. when there is some more complex expression like `someitem.width * 0.2`, etc — that should also work and should probably be included to the testcases.

      Attachments

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

        Activity

          People

            smd Jan Arve
            chalker Сковорода Никита
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes