PathAttribute Element Reference

The PathAttribute allows setting an attribute at a given position in a Path.

This element was introduced in Qt 4.7.

Detailed Description

The PathAttribute allows setting an attribute at a given position in a Path.

The PathAttribute object allows attributes consisting of a name and a value to be specified for various points along a path. The attributes are exposed to the delegate as Attached Properties. The value of an attribute at any particular point along the path is interpolated from the PathAttributes bounding that point.

The example below shows a path with the items scaled to 30% with opacity 50% at the top of the path and scaled 100% with opacity 100% at the bottom. Note the use of the PathView.iconScale and PathView.iconOpacity attached properties to set the scale and opacity of the delegate.

  1. import QtQuick 1.0
  2.  
  3. Rectangle  {
  4.     width: 240; height: 200
  5.  
  6.     Component  {
  7.         id: delegate
  8.         Item  {
  9.             width: 80; height: 80
  10.             scale: PathView.iconScale
  11.             opacity: PathView.iconOpacity
  12.             Column  {
  13.                 Image  { anchors.horizontalCenter: nameText.horizontalCenter; width: 64; height: 64; source: icon }
  14.                 Text  { id: nameText; text: name; font.pointSize: 16 }
  15.             }
  16.         }
  17.     }
  18.  
  19.     PathView  {
  20.         anchors.fill: parent
  21.         model: ContactModel  {}
  22.         delegate: delegate
  23.         path: Path  {
  24.             startX: 120; startY: 100
  25.             PathAttribute  { name: "iconScale"; value: 1.0 }
  26.             PathAttribute  { name: "iconOpacity"; value: 1.0 }
  27.             PathQuad  { x: 120; y: 25; controlX: 260; controlY: 75 }
  28.             PathAttribute  { name: "iconScale"; value: 0.3 }
  29.             PathAttribute  { name: "iconOpacity"; value: 0.5 }
  30.             PathQuad  { x: 120; y: 100; controlX: -20; controlY: 75 }
  31.         }
  32.     }
  33. }

(see the PathView documentation for the specification of ContactModel.qml used for ContactModel above.)

Properties

Property Documentation

This property holds the name of the attribute to change.

This attribute will be available to the delegate as PathView.<name>

Note that using an existing Item property name such as "opacity" as an attribute is allowed. This is because path attributes add a new Attached Property which in no way clashes with existing properties.

This property holds the value for the attribute.

The value specified can be used to influence the visual appearance of an item along the path. For example, the following Path specifies an attribute named itemRotation, which has the value 0 at the beginning of the path, and the value 90 at the end of the path.

  1.                 Path  {
  2.     startX: 0
  3.     startY: 0
  4.     PathAttribute  { name: "itemRotation"; value: 0 }
  5.     PathLine  { x: 100; y: 100 }
  6.     PathAttribute  { name: "itemRotation"; value: 90 }
  7. }

In our delegate, we can then bind the rotation property to the Attached Property PathView.itemRotation created for this attribute.

  1.                 Rectangle  {
  2.     width: 10; height: 10
  3.     rotation: PathView.itemRotation
  4. }

As each item is positioned along the path, it will be rotated accordingly: an item at the beginning of the path with be not be rotated, an item at the end of the path will be rotated 90 degrees, and an item mid-way along the path will be rotated 45 degrees.

Notes provided by the Qt Community

No notes