1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QPROGRESSBAR_H |
5 | #define QPROGRESSBAR_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qframe.h> |
9 | |
10 | QT_REQUIRE_CONFIG(progressbar); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QProgressBarPrivate; |
15 | class QStyleOptionProgressBar; |
16 | |
17 | class Q_WIDGETS_EXPORT QProgressBar : public QWidget |
18 | { |
19 | Q_OBJECT |
20 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) |
21 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) |
22 | Q_PROPERTY(QString text READ text) |
23 | Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) |
24 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) |
25 | Q_PROPERTY(bool textVisible READ isTextVisible WRITE setTextVisible) |
26 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) |
27 | Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance) |
28 | Q_PROPERTY(Direction textDirection READ textDirection WRITE setTextDirection) |
29 | Q_PROPERTY(QString format READ format WRITE setFormat RESET resetFormat) |
30 | |
31 | public: |
32 | enum Direction { TopToBottom, BottomToTop }; |
33 | Q_ENUM(Direction) |
34 | |
35 | explicit QProgressBar(QWidget *parent = nullptr); |
36 | ~QProgressBar(); |
37 | |
38 | int minimum() const; |
39 | int maximum() const; |
40 | |
41 | int value() const; |
42 | |
43 | virtual QString text() const; |
44 | void setTextVisible(bool visible); |
45 | bool isTextVisible() const; |
46 | |
47 | Qt::Alignment alignment() const; |
48 | void setAlignment(Qt::Alignment alignment); |
49 | |
50 | QSize sizeHint() const override; |
51 | QSize minimumSizeHint() const override; |
52 | |
53 | Qt::Orientation orientation() const; |
54 | |
55 | void setInvertedAppearance(bool invert); |
56 | bool invertedAppearance() const; |
57 | void setTextDirection(QProgressBar::Direction textDirection); |
58 | QProgressBar::Direction textDirection() const; |
59 | |
60 | void setFormat(const QString &format); |
61 | void resetFormat(); |
62 | QString format() const; |
63 | |
64 | public Q_SLOTS: |
65 | void reset(); |
66 | void setRange(int minimum, int maximum); |
67 | void setMinimum(int minimum); |
68 | void setMaximum(int maximum); |
69 | void setValue(int value); |
70 | void setOrientation(Qt::Orientation); |
71 | |
72 | Q_SIGNALS: |
73 | void valueChanged(int value); |
74 | |
75 | protected: |
76 | bool event(QEvent *e) override; |
77 | void paintEvent(QPaintEvent *) override; |
78 | virtual void initStyleOption(QStyleOptionProgressBar *option) const; |
79 | |
80 | private: |
81 | Q_DECLARE_PRIVATE(QProgressBar) |
82 | Q_DISABLE_COPY(QProgressBar) |
83 | }; |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif // QPROGRESSBAR_H |
88 | |