Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
12 QGraphicsItem *ball = new QGraphicsEllipseItem(0, 0, 20, 20);
13
14 QTimeLine *timer = new QTimeLine(5000);
15 timer->setFrameRange(0, 100);
16
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
25 scene->setSceneRect(0, 0, 250, 250);
26 scene->addItem(ball);
27
29 view->show();
30
31 timer->start();
33
34 return app.exec();
35}
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
The QGraphicsEllipseItem class provides an ellipse item that you can add to a QGraphicsScene.
The QGraphicsItemAnimation class provides simple animation support for QGraphicsItem.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
void addItem(QGraphicsItem *item)
Adds or moves the item and all its children to this scene.
void setSceneRect(const QRectF &rect)
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore
Definition qtimeline.h:19
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:241
void show()
Shows the window.
Definition qwindow.cpp:2254
int main()
[0]
QTimer * timer
[3]
QPropertyAnimation animation
[0]
QGraphicsScene scene
[0]
QApplication app(argc, argv)
[0]
QQuickView * view
[0]
QJSValueList args