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
src_corelib_animation_qpropertyanimation.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
6#include <QApplication>
7#include <QPushButton>
8#include <QPropertyAnimation>
9
10class MyButtonWidget : public QWidget
11{
12public:
13 MyButtonWidget(QWidget *parent = nullptr);
14};
15
17{
18 QPushButton *button = new QPushButton(tr("Animated Button"), this);
19 QPropertyAnimation *anim = new QPropertyAnimation(button, "pos", this);
20 anim->setDuration(10000);
21 anim->setStartValue(QPoint(0, 0));
22 anim->setEndValue(QPoint(100, 250));
23 anim->start();
24}
25
26int main(int argc, char *argv[])
27{
28 QApplication a(argc, argv);
29 MyButtonWidget buttonAnimWidget;
30 buttonAnimWidget.resize(QSize(800, 600));
31 buttonAnimWidget.show();
32 return a.exec();
33}
35
36
39{
40 QPushButton *button = new QPushButton(tr("Animated Button"), this);
41 QPropertyAnimation *anim = new QPropertyAnimation(button, "pos", this);
42 anim->setDuration(10000);
43 anim->setStartValue(QPoint(0, 0));
44 anim->setEndValue(QPoint(100, 250));
46 anim->start();
47}
49
50
53{
54 QPushButton *bonnie = new QPushButton(tr("Bonnie"), this);
55 QPushButton *clyde = new QPushButton(tr("Clyde"), this);
56
57 QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "pos", this);
58 anim1->setDuration(3000);
59 anim1->setStartValue(QPoint(0, 0));
60 anim1->setEndValue(QPoint(100, 250));
61
62 QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "pos", this);
63 anim2->setDuration(3000);
64 anim2->setStartValue(QPoint(100, 250));
65 anim2->setEndValue(QPoint(500, 500));
66
68 parallelAnim->addAnimation(anim1);
69 parallelAnim->addAnimation(anim2);
70 parallelAnim->start();
71}
73
76{
77 QPushButton *bonnie = new QPushButton(tr("Bonnie"), this);
78 QPushButton *clyde = new QPushButton(tr("Clyde"), this);
79
80 QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "pos", this);
81 anim1->setDuration(3000);
82 anim1->setStartValue(QPoint(0, 0));
83 anim1->setEndValue(QPoint(100, 250));
84
85 QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "pos", this);
86 anim2->setDuration(3000);
87 anim2->setStartValue(QPoint(0, 0));
88 anim2->setEndValue(QPoint(200, 250));
89
91 sequenceAnim->addAnimation(anim1);
92 sequenceAnim->addAnimation(anim2);
93 sequenceAnim->start();
94}
MyButtonWidget(QWidget *parent=nullptr)
[0]
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
void addAnimation(QAbstractAnimation *animation)
Adds animation to this group.
The QApplication class manages the GUI application's control flow and main settings.
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore\reentrant
Definition qpoint.h:25
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
\inmodule QtCore
Definition qsize.h:25
void setStartValue(const QVariant &value)
void setEasingCurve(const QEasingCurve &easing)
void setDuration(int msecs)
void setEndValue(const QVariant &value)
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
QPushButton
[1]
int main()
[0]
QPushButton * button
[2]
GLboolean GLboolean GLboolean GLboolean a
[7]
#define tr(X)