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

Item declared in a Node or Model creates an Item2D immediately; reparenting leaves behind an empty 2D subscene

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.0 Beta4
    • Quick: 3D
    • None
    • 3

    Description

      This came up in the hackathon: the green "blackboard" at the front of the space station is declared like this:

              Frame {
                  id: frame
                  objectName: "frame with green blackboard"
                  x: -90
                  y: 190
                  z: 100
                  w: 160
                  h: 90
                  eulerRotation.y: 90
      
                  TextEdit {
                      objectName: "blackboard text"
                      property int iviId: 1337
                      parent: frame.contentItem
                      anchors.fill: parent
                      text: "<- lasciate ogne speranza, voi ch'intrate\n\nTry editing the text here"
                      selectByMouse: true
                      wrapMode: TextEdit.Wrap
                  }
              }
      

      while Frame is declared like this:

      Node {
          id: rOOT
          property real w: 150
          property real h: 75
          property alias contentItem: contentRect
          PrincipledMaterial { ... }
          Node {
              scale: "100,100,100"
              Model { ... }
              Model { ... }
              ...
          }
          Node {
              id: contentNode
              x: w/200
              y: -h/200
              scale: "0.5, 0.5, 0.5"
              Rectangle {
                  id: contentRect
                  width: w*2
                  height: h*2
                  color: "lightgreen"
              }
          }
      }
      

      So Frame creates a 2D subscene because it has contentRect declared inside a Node, without a #Rectangle Model to give it a bounding region. That's OK, it can be corrected if we want to avoid having Item2D's at all (because of the infinite planes that they create). But clearly the idea is to reparent the TextEdit into that same 2D subscene. Instead though, we get another 2D subscene just for the TextEdit, which will then end up being empty after the reparenting! Its plane will interfere with event delivery even though it's empty. It is created in QQuick3DObjectPrivate::data_append(). Perhaps that should be put off until componentComplete or so.

      The attached example shows that even if you try to avoid creating an Item2D, if you do this reparenting trick you will end up creating an Item2D accidentally, and you will not be able to mouse the WasdController which is behind the scene (that's QTBUG-96457).

      [     1.267 D] qt.quick3d.pick QQuick3DViewport::internalPick - pick result: QQuick3DItem2D(0x555599b71de0) @ QVector3D(45.1119, -88.8839, 367.912) UV QVector2D(46.7033, 88.8839) dist 252.587 scene QPointF(46.7033,88.8839) QQuickItem(0x555599b7a820, name="parent of pressure-sensitive green/lightblue rect", parent=0x0, geometry=0,0 0x0) 

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-96514
          # Subject Branch Project Status CR V

          Activity

            People

              qt.team.graphics.and.multimedia Qt Graphics Team
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change