~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/demos-sub-attaq-qanimationstate-cpp.html

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<head>
 
6
  <title>Qt 4.6: qanimationstate.cpp Example File (demos/sub-attaq/qanimationstate.cpp)</title>
 
7
  <link href="classic.css" rel="stylesheet" type="text/css" />
 
8
</head>
 
9
<body>
 
10
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
11
<tr>
 
12
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
 
13
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td><td class="searchBar" align="right" valign="center"><form action="http://www.google.com/cse" id="cse-search-box"><div><input type="hidden" name="cx" value="000136343326384750312:dhbxnqlakyu" /><input type="hidden" name="ie" value="UTF-8" /><input type="text" name="q" size="31" /><input type="submit" name="sa" value="Search" /></div></form></td>
 
14
</tr></table><h1 class="title">qanimationstate.cpp Example File<br /><span class="small-subtitle">demos/sub-attaq/qanimationstate.cpp</span>
 
15
</h1>
 
16
<pre><span class="comment"> /****************************************************************************
 
17
 **
 
18
 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 
19
 ** All rights reserved.
 
20
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 
21
 **
 
22
 ** This file is part of the QtGui module of the Qt Toolkit.
 
23
 **
 
24
 ** $QT_BEGIN_LICENSE:LGPL$
 
25
 ** No Commercial Usage
 
26
 ** This file contains pre-release code and may not be distributed.
 
27
 ** You may use this file in accordance with the terms and conditions
 
28
 ** contained in the Technology Preview License Agreement accompanying
 
29
 ** this package.
 
30
 **
 
31
 ** GNU Lesser General Public License Usage
 
32
 ** Alternatively, this file may be used under the terms of the GNU Lesser
 
33
 ** General Public License version 2.1 as published by the Free Software
 
34
 ** Foundation and appearing in the file LICENSE.LGPL included in the
 
35
 ** packaging of this file.  Please review the following information to
 
36
 ** ensure the GNU Lesser General Public License version 2.1 requirements
 
37
 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
38
 **
 
39
 ** In addition, as a special exception, Nokia gives you certain additional
 
40
 ** rights.  These rights are described in the Nokia Qt LGPL Exception
 
41
 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
42
 **
 
43
 ** If you have questions regarding the use of this file, please contact
 
44
 ** Nokia at qt-info@nokia.com.
 
45
 **
 
46
 **
 
47
 **
 
48
 **
 
49
 **
 
50
 **
 
51
 **
 
52
 **
 
53
 ** $QT_END_LICENSE$
 
54
 **
 
55
 ****************************************************************************/</span>
 
56
 
 
57
 #include &quot;qanimationstate.h&quot;
 
58
 
 
59
 #include &lt;QtCore/qstate.h&gt;
 
60
 
 
61
<span class="comment"> /*!
 
62
 \class QAnimationState
 
63
 
 
64
 \brief The QAnimationState class provides state that handle an animation and emit
 
65
 a signal when this animation is finished.
 
66
 
 
67
 \ingroup statemachine
 
68
 
 
69
 QAnimationState provides a state that handle an animation. It will start this animation
 
70
 when the state is entered and stop it when it is leaved. When the animation has finished the
 
71
 state emit animationFinished signal.
 
72
 QAnimationState is part of \l{The State Machine Framework}.
 
73
 
 
74
 \code
 
75
 QStateMachine machine;
 
76
 QAnimationState *s = new QAnimationState(machine-&gt;rootState());
 
77
 QPropertyAnimation *animation = new QPropertyAnimation(obj, &quot;pos&quot;);
 
78
 s-&gt;setAnimation(animation);
 
79
 QState *s2 = new QState(machine-&gt;rootState());
 
80
 s-&gt;addTransition(s, SIGNAL(animationFinished()), s2);
 
81
 machine.start();
 
82
 \endcode
 
83
 
 
84
 \sa QState, {The Animation Framework}
 
85
 */</span>
 
86
 
 
87
 #ifndef QT_NO_ANIMATION
 
88
 
 
89
<span class="comment"> /*!
 
90
   Constructs a new state with the given \a parent state.
 
91
 */</span>
 
92
 QAnimationState::QAnimationState(QState *parent)
 
93
     : QState(parent), m_animation(0)
 
94
 {
 
95
 }
 
96
 
 
97
<span class="comment"> /*!
 
98
   Destroys the animation state.
 
99
 */</span>
 
100
 QAnimationState::~QAnimationState()
 
101
 {
 
102
 }
 
103
 
 
104
<span class="comment"> /*!
 
105
   Set an \a animation for this QAnimationState. If an animation was previously handle by this
 
106
   state then it won't emit animationFinished for the old animation. The QAnimationState doesn't
 
107
   take the ownership of the animation.
 
108
 */</span>
 
109
 void QAnimationState::setAnimation(QAbstractAnimation *animation)
 
110
 {
 
111
     if (animation == m_animation)
 
112
         return;
 
113
 
 
114
     <span class="comment">//Disconnect from the previous animation if exist</span>
 
115
     if(m_animation)
 
116
         disconnect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
 
117
 
 
118
     m_animation = animation;
 
119
 
 
120
     if (m_animation) {
 
121
         <span class="comment">//connect the new animation</span>
 
122
         connect(m_animation, SIGNAL(finished()), this, SIGNAL(animationFinished()));
 
123
     }
 
124
 }
 
125
 
 
126
<span class="comment"> /*!
 
127
   Returns the animation handle by this animation state, or 0 if there is no animation.
 
128
 */</span>
 
129
 QAbstractAnimation* QAnimationState::animation() const
 
130
 {
 
131
     return m_animation;
 
132
 }
 
133
 
 
134
<span class="comment"> /*!
 
135
   \reimp
 
136
 */</span>
 
137
 void QAnimationState::onEntry(QEvent *)
 
138
 {
 
139
     if (m_animation)
 
140
         m_animation-&gt;start();
 
141
 }
 
142
 
 
143
<span class="comment"> /*!
 
144
   \reimp
 
145
 */</span>
 
146
 void QAnimationState::onExit(QEvent *)
 
147
 {
 
148
     if (m_animation)
 
149
         m_animation-&gt;stop();
 
150
 }
 
151
 
 
152
<span class="comment"> /*!
 
153
   \reimp
 
154
 */</span>
 
155
 bool QAnimationState::event(QEvent *e)
 
156
 {
 
157
     return QState::event(e);
 
158
 }
 
159
 
 
160
 
 
161
 #endif</pre>
 
162
<p /><address><hr /><div align="center">
 
163
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
164
<td width="40%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
 
165
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
166
<td width="40%" align="right"><div align="right">Qt 4.6.0</div></td>
 
167
<script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script><script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en"></script><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script></tr></table></div></address></body>
 
168
</html>