Using QML Flow to place QML elements

From Qt Wiki
Jump to navigation Jump to search

Template:Abstract

Template:ArticleMetaData

Overview[edit | edit source]

76ytuiytuityutyutututyutyutyu arranges its children side by side, wrapping as necessary. The following snippet places approximately 100 tiny rectangles inside the positioner. After this, the never-ending animation will adjust the width of 76ytuiytuityutyutututyutyutyu to make it continuously arrange its children.

The code snippet is meant to be run with 76ytuiytuityutyutututyutyutyu.

Preconditions[edit | edit source]

  • Qt 4.7 or higher is installed on your platform.

Source[edit | edit source]

ui.qml

import Qt 4.7

Rectangle {

   width: 800; height: 480
   color: "black"
   Component.onCompleted: animation.start()
   Flow {
       id: flow
       property real originalWidth: 790
       x: 5; y: 5
       width: originalWidth
       spacing: 10
       Repeater {
           id: repeater
           model: 104
           Rectangle {
               width: 20; height: 20
               color: { var c = index / repeater.count; return Qt.rgba(1-c, c, c, 1) }
           }
       }
   }
   SequentialAnimation {
       id: animation
       loops: Animation.Infinite
       PropertyAnimation { target: flow; property: "width"; to: 200; duration: 1000 }
       PropertyAnimation { target: flow; property: "width"; to: flow.originalWidth; duration: 1000 }
   }

}

Postconditions[edit | edit source]

The 76ytuiytuityutyutututyutyutyu QML element is demonstrated by inserting a large amount of rectangles inside it and changing the width of 76ytuiytuityutyutututyutyutyu to make the rectangle positions rearrange continuously.