src/declarative/util/qdeclarativepropertychanges.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    60 QT_BEGIN_NAMESPACE
    60 QT_BEGIN_NAMESPACE
    61 
    61 
    62 /*!
    62 /*!
    63     \qmlclass PropertyChanges QDeclarativePropertyChanges
    63     \qmlclass PropertyChanges QDeclarativePropertyChanges
    64     \since 4.7
    64     \since 4.7
    65     \brief The PropertyChanges element describes new property values for a state.
    65     \brief The PropertyChanges element describes new property bindings or values for a state.
    66 
    66 
    67     PropertyChanges provides a state change that modifies the properties of an item.
    67     PropertyChanges provides a state change that modifies the properties of an item.
    68 
    68 
    69     Here is a property change that modifies the text and color of a Text element
    69     Here is a property change that modifies the text and color of a \l Text element
    70     when it is clicked:
    70     when it is clicked:
    71     
    71     
    72     \qml
    72     \qml
    73     Text {
    73     Text {
    74         id: myText
    74         id: myText
    87         }
    87         }
    88 
    88 
    89         MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
    89         MouseArea { anchors.fill: parent; onClicked: myText.state = 'myState' }
    90     }
    90     }
    91     \endqml
    91     \endqml
       
    92 
       
    93     By default, PropertyChanges will establish new bindings where appropriate.
       
    94     For example, the following creates a new binding for myItem's \c height property.
       
    95 
       
    96     \qml
       
    97     PropertyChanges {
       
    98         target: myItem
       
    99         height: parent.height
       
   100     }
       
   101     \endqml
       
   102 
       
   103     If you don't want a binding to be established (and instead just want to assign
       
   104     the value of the binding at the time the state is entered),
       
   105     you should set the PropertyChange's \l{PropertyChanges::explicit}{explicit}
       
   106     property to \c true.
    92     
   107     
    93     State-specific script for signal handlers can also be specified:
   108     State-specific script for signal handlers can also be specified:
    94 
   109 
    95     \qml
   110     \qml
    96     PropertyChanges {
   111     PropertyChanges {
   128 
   143 
   129     Anchor margins should be changed with PropertyChanges, but other anchor changes or changes to
   144     Anchor margins should be changed with PropertyChanges, but other anchor changes or changes to
   130     an Item's parent should be done using the associated change elements
   145     an Item's parent should be done using the associated change elements
   131     (ParentChange and AnchorChanges, respectively).
   146     (ParentChange and AnchorChanges, respectively).
   132 
   147 
   133     \sa {qmlstate}{States}, QtDeclarative
   148     \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative
   134 */
   149 */
   135 
   150 
   136 /*!
   151 /*!
   137     \internal
   152     \internal
   138     \class QDeclarativePropertyChanges
   153     \class QDeclarativePropertyChanges
   483     \qmlproperty bool PropertyChanges::explicit
   498     \qmlproperty bool PropertyChanges::explicit
   484 
   499 
   485     If explicit is set to true, any potential bindings will be interpreted as
   500     If explicit is set to true, any potential bindings will be interpreted as
   486     once-off assignments that occur when the state is entered.
   501     once-off assignments that occur when the state is entered.
   487 
   502 
   488     In the following example, the addition of explicit prevents myItem.width from
   503     In the following example, the addition of explicit prevents \c myItem.width from
   489     being bound to parent.width. Instead, it is assigned the value of parent.width
   504     being bound to \c parent.width. Instead, it is assigned the value of \c parent.width
   490     at the time of the state change.
   505     at the time of the state change.
   491     \qml
   506     \qml
   492     PropertyChanges {
   507     PropertyChanges {
   493         target: myItem
   508         target: myItem
   494         explicit: true
   509         explicit: true