QProgressBar Class

QProgressBar 위젯은 가로 또는 세로 진행률 표시줄을 제공합니다. 더 보기...

헤더: #include <QProgressBar>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
상속합니다: QWidget

공용 유형

enum Direction { TopToBottom, BottomToTop }

속성

공용 함수

QProgressBar(QWidget *parent = nullptr)
virtual ~QProgressBar()
Qt::Alignment alignment() const
QString format() const
bool invertedAppearance() const
bool isTextVisible() const
int maximum() const
int minimum() const
Qt::Orientation orientation() const
void resetFormat()
void setAlignment(Qt::Alignment alignment)
void setFormat(const QString &format)
void setInvertedAppearance(bool invert)
void setTextDirection(QProgressBar::Direction textDirection)
void setTextVisible(bool visible)
virtual QString text() const
QProgressBar::Direction textDirection() const
int value() const

재구현된 공용 함수

virtual QSize minimumSizeHint() const override
virtual QSize sizeHint() const override

공용 슬롯

void reset()
void setMaximum(int maximum)
void setMinimum(int minimum)
void setOrientation(Qt::Orientation)
void setRange(int minimum, int maximum)
void setValue(int value)

신호

void valueChanged(int value)

보호된 함수

virtual void initStyleOption(QStyleOptionProgressBar *option) const

재구현된 보호 함수

virtual bool event(QEvent *e) override
virtual void paintEvent(QPaintEvent *) override

상세 설명

진행률 표시줄은 사용자에게 작업의 진행 상황을 표시하고 애플리케이션이 계속 실행 중임을 알려주는 데 사용됩니다.

진행률 표시줄은 단계의 개념을 사용합니다. 가능한 최소 및 최대 단계 값을 지정하여 설정하면 나중에 현재 단계 값을 지정할 때 완료된 단계의 백분율을 표시합니다. 백분율은 진행률(value() - minimum())을 maximum() - minimum()으로 나누어 계산합니다.

setMinimum() 및 setMaximum 을 사용하여 최소 및 최대 걸음 수를 지정할 수 있습니다. 현재 단계 수는 setValue()로 설정합니다. 진행률 표시줄은 reset()를 사용하여 처음으로 되돌릴 수 있습니다.

최소값과 최대값이 모두 0으로 설정되어 있으면 진행률 표시줄에 걸음 수 백분율 대신 사용 중 표시기가 표시됩니다. 예를 들어 다운로드 중인 항목의 크기를 확인할 수 없을 때 QNetworkAccessManager 을 사용하여 항목을 다운로드할 때 유용합니다.

QProgressDialog참조하세요 .

회원 유형 문서

enum QProgressBar::Direction

세로 진행률 표시줄의 읽기 방향( text )을 지정합니다.

Constant설명
QProgressBar::TopToBottom0텍스트가 시계 방향으로 90도 회전합니다.
QProgressBar::BottomToTop1텍스트가 시계 반대 방향으로 90도 회전합니다.

텍스트가 그려지는지 여부는 스타일에 따라 달라집니다. 현재 클린룩과 플라스티크는 텍스트를 그립니다. Mac, Windows 및 WindowsVista 스타일은 그렇지 않습니다.

textDirection참조하세요 .

속성 문서

alignment : Qt::Alignment

이 속성은 진행률 표시줄의 정렬을 유지합니다.

액세스 함수:

Qt::Alignment alignment() const
void setAlignment(Qt::Alignment alignment)

format : QString

이 속성은 현재 텍스트를 생성하는 데 사용되는 문자열을 보유합니다.

p - 완료된 백분율로 대체됩니다. v - 현재 값으로 대체됩니다. m - 총 단계 수로 대체됩니다.

기본값은 "%p%"입니다.

함수에 접근합니다:

QString format() const
void setFormat(const QString &format)
void resetFormat()

text()도 참조하세요 .

invertedAppearance : bool

이 속성은 진행률 표시줄이 거꾸로 표시되는지 여부를 유지합니다.

이 속성이 true 인 경우 진행률 표시줄이 반대 방향(예: 오른쪽에서 왼쪽)으로 늘어납니다. 기본적으로 진행률 표시줄은 반전되지 않습니다.

함수 액세스:

bool invertedAppearance() const
void setInvertedAppearance(bool invert)

orientationlayoutDirection참조하세요 .

maximum : int

이 속성은 진행률 표시줄의 최대값을 유지합니다.

이 속성을 설정할 때 필요한 경우 범위가 유효한지 확인하기 위해 minimum 가 조정됩니다. 현재 값이 새 범위를 벗어나면 진행률 표시줄은 reset()로 재설정됩니다.

함수 액세스:

int maximum() const
void setMaximum(int maximum)

minimum : int

이 속성은 진행률 표시줄의 최소값을 유지합니다.

이 속성을 설정할 때 필요한 경우 범위가 유효한지 확인하기 위해 maximum 가 조정됩니다. 현재 값이 새 범위를 벗어나면 진행률 표시줄은 reset()로 재설정됩니다.

함수 액세스:

int minimum() const
void setMinimum(int minimum)

orientation : Qt::Orientation

이 속성은 진행률 표시줄의 방향을 유지합니다.

방향은 Qt::Horizontal (기본값) 또는 Qt::Vertical 이어야 합니다.

액세스 함수입니다:

Qt::Orientation orientation() const
void setOrientation(Qt::Orientation)

invertedAppearancetextDirection참조하세요 .

[read-only] text : const QString

이 속성에는 진행률 표시줄과 함께 표시되는 설명 텍스트가 저장됩니다.

반환되는 텍스트는 진행률 표시줄의 중앙(또는 일부 스타일에서는 왼쪽)에 표시되는 텍스트와 동일합니다.

텍스트에 표시되는 진행률은 최소값보다 작을 수 있으며, 이는 진행률이 설정되기 전에 진행률 표시줄이 '초기화' 상태임을 나타냅니다.

기본 구현에서는 텍스트에 지금까지의 진행률을 나타내는 백분율 값이 포함되어 있거나 진행률 표시줄이 재설정 상태이므로 공백으로 표시됩니다.

기능에 액세스합니다:

virtual QString text() const

textDirection : Direction

이 속성은 수직 진행률 표시줄의 경우 text 의 읽기 방향을 유지합니다.

이 속성은 가로 진행률 표시줄에는 영향을 미치지 않습니다. 기본적으로 읽기 방향은 QProgressBar::TopToBottom 입니다.

함수에 액세스합니다:

QProgressBar::Direction textDirection() const
void setTextDirection(QProgressBar::Direction textDirection)

orientationtextVisible참조하세요 .

textVisible : bool

이 속성은 현재 완료된 백분율을 표시할지 여부를 보유합니다.

이 속성은 스타일에 의해 무시될 수 있습니다(예: QMacStyle은 텍스트를 그리지 않음).

함수에 접근합니다:

bool isTextVisible() const
void setTextVisible(bool visible)

textDirection참조하십시오 .

value : int

이 속성은 진행률 표시줄의 현재 값을 유지합니다.

현재 값을 최소-최대 범위를 벗어난 값으로 변경하려고 시도해도 현재 값에는 영향을 미치지 않습니다.

기능에 액세스합니다:

int value() const
void setValue(int value)

알림 신호:

void valueChanged(int value)

멤버 함수 문서

[explicit] QProgressBar::QProgressBar(QWidget *parent = nullptr)

주어진 parent 으로 진행률 표시줄을 만듭니다.

기본적으로 최소 단계 값은 0으로, 최대 단계 값은 100으로 설정됩니다.

setRange()도 참조하세요 .

[virtual noexcept] QProgressBar::~QProgressBar()

파괴자.

[override virtual protected] bool QProgressBar::event(QEvent *e)

다시 구현합니다: QWidget::event(QEvent * 이벤트).

[virtual protected] void QProgressBar::initStyleOption(QStyleOptionProgressBar *option) const

QProgressBar 의 값으로 option 을 초기화합니다. 이 메서드는 하위 클래스에 QStyleOptionProgressBar 이 필요하지만 모든 정보를 직접 채우고 싶지 않을 때 유용합니다.

QStyleOption::initFrom()도 참조하세요 .

[override virtual] QSize QProgressBar::minimumSizeHint() const

속성에 대한 액세스 함수를 다시 구현합니다: QWidget::minimumSizeHint.

[override virtual protected] void QProgressBar::paintEvent(QPaintEvent *)

다시 구현합니다: QWidget::paintEvent(QPaintEvent * 이벤트).

[slot] void QProgressBar::reset()

진행률 표시줄을 재설정합니다. 진행률 표시줄이 "되감기"되고 진행률이 표시되지 않습니다.

[slot] void QProgressBar::setRange(int minimum, int maximum)

진행률 표시줄의 최소값과 최대값을 각각 minimummaximum 으로 설정합니다.

maximumminimum 보다 작으면 minimum 이 유일한 법적 값이 됩니다.

현재 값이 새 범위를 벗어나면 진행률 표시줄은 reset()로 재설정됩니다.

QProgressBar 은 setRange(0, 0)를 사용하여 미정 상태로 설정할 수 있습니다.

minimummaximum참조하세요 .

[override virtual] QSize QProgressBar::sizeHint() const

속성에 대한 액세스 함수를 다시 구현합니다: QWidget::sizeHint.

[signal] void QProgressBar::valueChanged(int value)

이 신호는 진행률 표시줄에 표시된 값이 변경될 때 발생합니다. value 진행률 표시줄에 표시되는 새 값입니다.

참고: value 속성에 대한 알림 신호입니다.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.