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

Replacing a GridLayout cell with a repeater complains

    XMLWordPrintable

    Details

      Description

      The example uses two Repeaters to set the columns of a GridLayout. The first repeater does the first column and the second does the second column. Inside the repeater the cell is set explicitly with Layout.row and Layout.column.

       

      The code below can also be found in this gist/git repo. https://gist.github.com/Siecje/27f41128863bf8bcbe3ab2a054c67dd7

      The output is as follows

      QGridLayoutEngine::addItem: Cell (0, 0) already taken
      QGridLayoutEngine::addItem: Cell (0, 0) already taken
      QGridLayoutEngine::addItem: Cell (0, 1) already taken
      QGridLayoutEngine::addItem: Cell (0, 1) already taken
      

      Run this file with qmlscene and then click the button to see the error in the terminal.

      import QtQuick 2.7
      import QtQuick.Controls 1.4
      import QtQuick.Layouts 1.3 as Layouts
      
      Item {
          id: base
          property var categories: ['one', 'two', 'three']
          property var values: [1, 2, 3]
          width: 800
          height: 600
      
          Column {
            Button {
              text: "Cause error output"
              onClicked: {
                base.categories = ['eleven', 'twelve']
                base.values = [11, 12]
              }
            }
            Button {
              text: "DOES NOT Cause error output"
              onClicked: {
                base.categories = ['eleven']
                base.values = [11]
              }
            }
          }
      
          Layouts.GridLayout {
            anchors.fill: parent
            columns: 2
      
            // CATEGORY LABELS...
            Repeater {
                model: base.categories // modelData will be the categories
                Item {
                    Layouts.Layout.row: index
                    Layouts.Layout.column: 0
                    Layouts.Layout.preferredWidth: _categoryLabel.width
                    Layouts.Layout.fillHeight: true
                    // The actual category label...
                    Text {
                        id: _categoryLabel
                        height: parent.height
                        anchors.right: parent.right
                        text: modelData
                        verticalAlignment: Text.AlignVCenter
                        font.pointSize: 27
                        leftPadding: 10
                    }
                }
            }
      
            Repeater {
                model: base.values // modelData will be the values
                Item {
                    Layouts.Layout.row: index
                    Layouts.Layout.column: 1
                    Layouts.Layout.preferredWidth: _categoryLabel.width
                    Layouts.Layout.fillHeight: true
                    // The actual value label...
                    Text {
                        id: _categoryLabel
                        height: parent.height
                        anchors.right: parent.right
                        text: modelData
                        verticalAlignment: Text.AlignVCenter
                        font.pointSize: 27
                        leftPadding: 10
                    }
                }
            }
        }
      }
      

        Attachments

        Gerrit Reviews Web Panel

        Error rendering 'com.meetme.plugins.jira.gerrit-plugin:gerritreviewsmodule'. Please contact your Jira administrators.

          Activity

            People

            • Assignee:
              mitch_curtis Mitch Curtis
              Reporter:
              code Cody Scott
            • Votes:
              11 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews Side Panel

                Error rendering 'com.meetme.plugins.jira.gerrit-plugin:gerrit-reviews-side-panel'. Please contact your Jira administrators.