Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5#include <math.h>
6
7int main(int argv, char *args[])
8{
9 QApplication app(argv, args);
10
11 //! [0]
12 QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
13
14 QTimeLine *timer = new QTimeLine(5000);
15 timer->setFrameRange(0, 100);
16
17 QGraphicsItemAnimation *animation = new QGraphicsItemAnimation;
18 animation->setItem(ball);
19 animation->setTimeLine(timer);
20
21 for (int i = 0; i < 200; ++i)
22 animation->setPosAt(i / 200.0, QPointF(i, i));
23
24 QGraphicsScene *scene = new QGraphicsScene;
25 scene->setSceneRect(0, 0, 250, 250);
26 scene->addItem(ball);
27
28 QGraphicsView *view = new QGraphicsView(scene);
29 view->show();
30
31 timer->start();
32 //! [0]
33
34 return app.exec();
35}
int main(int argc, char *argv[])
[ctor_close]