|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QApplication> |
|
43 #include <QLabel> |
|
44 #include <QPropertyAnimation> |
|
45 #include <QSequentialAnimationGroup> |
|
46 #include "tracer.h" |
|
47 |
|
48 int main(int argc, char *argv[]) |
|
49 { |
|
50 QApplication app(argc, argv); |
|
51 |
|
52 QWidget window; |
|
53 window.resize(720, 96); |
|
54 window.show(); |
|
55 |
|
56 QLabel *label1 = new QLabel(&window); |
|
57 label1->setPixmap(QPixmap(":/icons/left.png")); |
|
58 label1->move(16, 16); |
|
59 label1->show(); |
|
60 |
|
61 QLabel *label2 = new QLabel(&window); |
|
62 label2->setPixmap(QPixmap(":/icons/right.png")); |
|
63 label2->move(320, 16); |
|
64 label2->show(); |
|
65 |
|
66 QPropertyAnimation *anim1 = new QPropertyAnimation(label1, "pos"); |
|
67 anim1->setDuration(2500); |
|
68 anim1->setStartValue(QPoint(16, 16)); |
|
69 anim1->setEndValue(QPoint(320, 16)); |
|
70 |
|
71 QPropertyAnimation *anim2 = new QPropertyAnimation(label2, "pos"); |
|
72 anim2->setDuration(2500); |
|
73 anim2->setStartValue(QPoint(320, 16)); |
|
74 anim2->setEndValue(QPoint(640, 16)); |
|
75 |
|
76 QSequentialAnimationGroup group; |
|
77 group.addAnimation(anim1); |
|
78 group.addAnimation(anim2); |
|
79 |
|
80 Tracer tracer(&window); |
|
81 |
|
82 QObject::connect(anim1, SIGNAL(valueChanged(QVariant)), |
|
83 &tracer, SLOT(recordValue(QVariant))); |
|
84 QObject::connect(anim2, SIGNAL(valueChanged(QVariant)), |
|
85 &tracer, SLOT(recordValue(QVariant))); |
|
86 QObject::connect(anim1, SIGNAL(finished()), &tracer, SLOT(checkValue())); |
|
87 QObject::connect(anim2, SIGNAL(finished()), &tracer, SLOT(checkValue())); |
|
88 |
|
89 group.start(); |
|
90 return app.exec(); |
|
91 } |