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

Adding content into Flickable using Qt.createObject not working

    XMLWordPrintable

Details

    • 9d6ccfea89ae99b747f70ece71185868f189d0f9

    Description

      Creating new content inside Flickable using createObject() doesn't make it part of the "flickable" content. Instead the newly created item stays still while rest of the flickable content moves. Confirmed with current Qt 4.7 gitorious upstream.

      Small example code:

      // dynamic_flickable.qml
      import Qt 4.7

      Flickable {
      id: myFlickable
      width: 400; height: 400
      contentWidth: 600; contentHeight: 600

      Rectangle {
      id: rect
      x:100; y:100
      width: 200; height: 200
      color: "blue"
      MouseArea {
      anchors.fill: parent
      onClicked:

      { console.debug("create content") var tempcomponent = Qt.createComponent("Box.qml") var tempitem = tempcomponent.createObject(myFlickable); }

      }
      }
      }

      // Box.qml
      import Qt 4.7

      Rectangle {
      color: "red"
      width: 100
      height: 100
      }

      Outcome: Clicking the blue rectangle creates a red rectangle. When flicking, blue rectangle moves as expected, but red stays in top-left corner.

      Workaround: The workaround I used now is to create extra Item inside Flickable which takes all the content and then with createObject() create new content to be inside this item instead the flickable.

      Attachments

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

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            kgronholm Kaj Grönholm (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes