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

GridLayout does not handle spans larger than the layout extent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.2.1
    • 5.2.0
    • Quick: Layouts
    • None
    • Ubuntu 13.04 64-bit
      Qt 5.2.0 from the official installer for Linux
      QtCreator 3.0.0 (based on Qt 5.2.0 built using GCC 4.6.1 64-bit) from the official installer for Linux
    • 7e8dc84430426180c7489cf2d29c36ed8b54c0c3

    Description

      When creating a layout based on GridLayout with dynamic columns number dependent on current window size, GridLayout behaves properly allowing to change said columns number.
      However, attempting to also change column span for certain elements depending on current window size causes qmlscene to hang indefinitely and freezes the window. This happens because the columnSpan becomes larger than columns.


      What is being done:
      A test .qml file

      import QtQuick 2.0
      import QtQuick.Controls 1.1
      import QtQuick.Layouts 1.1
      
      GridLayout {
          width: 300
          height: 500
          columns: (width > 300) ? 3 : 2
      
          Label {
              text: "First label"
              Layout.columnSpan: columns
          }
          Label {
              text: "Second label"
              Layout.columnSpan: columns
          }
          Label { text: "Third label" }
          Label { text: "Fourth label" }
          Label { text: "Fifth label" }
          Label { text: "Sixth label" }
      }

      1. Open the test file in qmlscene.
      2. Change width of the window to some greater-than-300 value.
      3. Change width of the window to some lower-than-301 value.

      What happens:
      Upon lowering the size below 301, the qmlscene hangs and the window freezes indefinitely.

      What should happen instead:
      Upon lowering the size below 301, the GridLayout should fall back to using two columns instead of three and the application should keep working properly.

      What probably happens:
      The issue at hand is probably caused by changing the GridLayout columns count before changing the columnSpan for the contained elements. This does not happen if columnSpan of elements is set to columns - 1.

      If deemed as a bug, a potential solution would involve always lowering the columnSpan value of an element to the parent Layout columns property.

      Attachments

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

        Activity

          People

            smd Jan Arve
            aleksmierciak Anonymous (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes