QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
qprogressindicator.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2011 Morgan Leborgne
2
// SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
3
// SPDX-License-Identifier: MIT
8
#ifndef SRC_QPROGRESSINDICATOR_H_
9
#define SRC_QPROGRESSINDICATOR_H_
10
11
#include <QColor>
12
#include <QWidget>
13
27
class
QProgressIndicator
:
public
QWidget {
28
Q_OBJECT
29
30
public
:
36
explicit
QProgressIndicator
(QWidget *parent =
nullptr
);
37
43
[[nodiscard]]
auto
animationDelay
() const ->
int
{
return
m_delay
; }
44
50
[[nodiscard]]
auto
isAnimated
() const ->
bool
;
51
57
[[nodiscard]] auto
isDisplayedWhenStopped
() const ->
bool
;
58
64
[[nodiscard]] auto
color
() const -> const QColor & {
return
m_color
; }
65
70
[[nodiscard]]
auto
sizeHint
() const -> QSize override;
71
77
[[nodiscard]] auto
heightForWidth
(
int
w) const ->
int
override;
78
79
public slots:
84
void
startAnimation
();
85
90
void
stopAnimation
();
91
101
void
setAnimationDelay
(
int
delay);
102
108
void
setDisplayedWhenStopped
(
bool
state);
109
116
void
setColor
(const QColor &
color
);
117
118
protected:
123
void
timerEvent
(QTimerEvent *event) override;
124
129
void
paintEvent
(QPaintEvent *event) override;
130
131
private:
133
int
m_angle
{0};
135
int
m_timerId
{-1};
137
int
m_delay
{40};
139
bool
m_displayedWhenStopped
{
false
};
141
QColor
m_color
;
142
};
143
144
#endif
// SRC_QPROGRESSINDICATOR_H_
QProgressIndicator::animationDelay
auto animationDelay() const -> int
Delay between animation steps.
Definition
qprogressindicator.h:43
QProgressIndicator::paintEvent
void paintEvent(QPaintEvent *event) override
Draw the twelve capsules, the newest opaque and the rest fading.
Definition
qprogressindicator.cpp:74
QProgressIndicator::m_color
QColor m_color
Colour from setColor(); invalid means the palette colour.
Definition
qprogressindicator.h:141
QProgressIndicator::m_angle
int m_angle
Rotation of the first capsule, in degrees.
Definition
qprogressindicator.h:133
QProgressIndicator::stopAnimation
void stopAnimation()
Stop the spin animation.
Definition
qprogressindicator.cpp:36
QProgressIndicator::QProgressIndicator
QProgressIndicator(QWidget *parent=nullptr)
Create a stopped indicator with a fixed size policy that never takes keyboard focus.
Definition
qprogressindicator.cpp:11
QProgressIndicator::isAnimated
auto isAnimated() const -> bool
Whether the indicator is animating.
Definition
qprogressindicator.cpp:16
QProgressIndicator::startAnimation
void startAnimation()
Start the spin animation from its first position.
Definition
qprogressindicator.cpp:28
QProgressIndicator::isDisplayedWhenStopped
auto isDisplayedWhenStopped() const -> bool
Whether the indicator is drawn while it does not animate.
Definition
qprogressindicator.cpp:24
QProgressIndicator::setColor
void setColor(const QColor &color)
Set the colour the indicator is drawn in.
Definition
qprogressindicator.cpp:58
QProgressIndicator::timerEvent
void timerEvent(QTimerEvent *event) override
Turn the indicator one step (30 degrees) and repaint.
Definition
qprogressindicator.cpp:68
QProgressIndicator::m_displayedWhenStopped
bool m_displayedWhenStopped
Whether the indicator is drawn while it does not animate.
Definition
qprogressindicator.h:139
QProgressIndicator::setDisplayedWhenStopped
void setDisplayedWhenStopped(bool state)
Set whether the indicator is drawn while it does not animate.
Definition
qprogressindicator.cpp:18
QProgressIndicator::m_delay
int m_delay
Milliseconds between two animation steps.
Definition
qprogressindicator.h:137
QProgressIndicator::setAnimationDelay
void setAnimationDelay(int delay)
Set the delay between animation steps.
Definition
qprogressindicator.cpp:46
QProgressIndicator::m_timerId
int m_timerId
Id of the animation timer, or -1 while stopped.
Definition
qprogressindicator.h:135
QProgressIndicator::heightForWidth
auto heightForWidth(int w) const -> int override
Keep the indicator square.
Definition
qprogressindicator.cpp:66
QProgressIndicator::sizeHint
auto sizeHint() const -> QSize override
Preferred size of the indicator.
Definition
qprogressindicator.cpp:64
QProgressIndicator::color
auto color() const -> const QColor &
Colour set with setColor().
Definition
qprogressindicator.h:64
src
qprogressindicator.h
Generated by
1.18.0