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

Item::childAt() returns an object at (x,y) while there is no any real object at (x,y)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.7.0 Alpha
    • 5.2.1, 5.3.2
    • Quick: Other
    • None
    • Windows 7 32-bit, Qt installers from Digia, MinGW 4.8
    • fb2710a7f182ffb910f6b121e8bc125a4f61dcdf

    Description

      Consider the following code. We have a rectangle 16 points width. childAt() counts 17 points.

      import QtQuick 2.0
      import QtQuick.Window 2.0
      
      Window {
          visible: true
          color: "steelblue"
      
          Item {
              id: rect
              anchors.fill: parent
      
              Rectangle {
                  color: "red"
                  x: 0
                  y: 0
                  width: 16
                  height: 10
              }
          }
      
          Component.onCompleted: {
              var found = 0;
      
              for(var i = 0;i < 18;i++)
              {
                  var block = rect.childAt(i, 0);
      
                  console.log("" + i + ": " + block);
      
                  if(block !== null)
                      found++;
              }
      
              console.log("Found " + found);
          }
      }

      Output:

      qml: 0: QQuickRectangle(0x2abb2b8)
      qml: 1: QQuickRectangle(0x2abb2b8)
      qml: 2: QQuickRectangle(0x2abb2b8)
      qml: 3: QQuickRectangle(0x2abb2b8)
      qml: 4: QQuickRectangle(0x2abb2b8)
      qml: 5: QQuickRectangle(0x2abb2b8)
      qml: 6: QQuickRectangle(0x2abb2b8)
      qml: 7: QQuickRectangle(0x2abb2b8)
      qml: 8: QQuickRectangle(0x2abb2b8)
      qml: 9: QQuickRectangle(0x2abb2b8)
      qml: 10: QQuickRectangle(0x2abb2b8)
      qml: 11: QQuickRectangle(0x2abb2b8)
      qml: 12: QQuickRectangle(0x2abb2b8)
      qml: 13: QQuickRectangle(0x2abb2b8)
      qml: 14: QQuickRectangle(0x2abb2b8)
      qml: 15: QQuickRectangle(0x2abb2b8)
      qml: 16: QQuickRectangle(0x2abb2b8)
      qml: 17: null
      qml: Found 17

      Attachments

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

        Activity

          People

            kahautam Kari Hautamäki
            dmitry64 Dmitry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes