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
src_corelib_tools_qtimeline.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 <QWidget>
5#include <QProgressBar>
6#include <QPushButton>
7#include <QTimeLine>
8
9struct MyObject : public QWidget
10{
11 void examples()
12 {
13 //! [0]
14 //...
15 auto progressBar = new QProgressBar(this);
16 progressBar->setRange(0, 100);
17
18 // Construct a 1-second timeline with a frame range of 0 - 100
19 QTimeLine *timeLine = new QTimeLine(1000, this);
20 timeLine->setFrameRange(0, 100);
21 connect(timeLine, &QTimeLine::frameChanged, progressBar, &QProgressBar::setValue);
22
23 // Clicking the push button will start the progress bar animation
24 auto pushButton = new QPushButton(tr("Start animation"), this);
25 connect(pushButton, &QPushButton::clicked, timeLine, &QTimeLine::start);
26 //...
27 //! [0]
28 }
29};