返回介绍

QProgressBar Class

发布于 2019-10-04 15:02:03 字数 8549 浏览 798 评论 0 收藏 0

The QProgressBar widget provides a horizontal progress bar. More...

#include <qprogressbar.h>

Inherits QFrame.

List of all member functions.

Public Members

  • QProgressBar ( QWidget*parent = 0, constchar*name = 0, WFlagsf = 0 )
  • QProgressBar ( inttotalSteps, QWidget*parent = 0, constchar*name = 0, WFlagsf = 0 )
  • int totalSteps () const
  • int progress () const
  • const QString & progressString () const
  • void setCenterIndicator ( boolon )
  • bool centerIndicator () const
  • void setIndicatorFollowsStyle ( bool )
  • bool indicatorFollowsStyle () const
  • bool percentageVisible () const
  • void setPercentageVisible ( bool )

Public Slots

  • void reset ()
  • virtual void setTotalSteps ( inttotalSteps )
  • virtual void setProgress ( intprogress )

Properties

  • bool centerIndicator- whether the indicator string should be centered
  • bool indicatorFollowsStyle- whether the display of the indicator string should follow the GUI style
  • bool percentageVisible- whether the current progress value is displayed
  • int progress- the current amount of progress
  • QString progressString- the current amount of progress as a string (read only)
  • int totalSteps- the total number of steps

Protected Members

  • virtual bool setIndicator ( QString&indicator, intprogress, inttotalSteps )

Detailed Description

The QProgressBar widget provides a horizontal progress bar.

A progress bar is used to give the user an indication of the progress of an operation and to reassure them that the application is still running.

The progress bar uses the concept of steps; you give it the total number of steps and the number of steps completed so far and it will display the percentage of steps that have been completed. You can specify the total number of steps in the constructor or later with setTotalSteps(). The current number of steps is set with setProgress(). The progress bar can be rewound to the beginning with reset().

See also QProgressDialog, GUI Design Handbook: Progress Indicator and Advanced Widgets.

See also QProgressDialog, GUI Design Handbook: Progress Indicator and Advanced Widgets.


Member Function Documentation

QProgressBar::QProgressBar ( QWidget*parent = 0, constchar*name = 0, WFlagsf = 0 )

Constructs a progress bar.

The total number of steps is set to 100 by default.

The parent, name and widget flags, f, are passed on to the QFrame::QFrame() constructor.

See also totalSteps.

QProgressBar::QProgressBar ( inttotalSteps, QWidget*parent = 0, constchar*name = 0, WFlagsf = 0 )

Constructs a progress bar.

The totalSteps is the total number of steps that need to be completed for the operation which this progress bar represents. For example, if the operation is to examine 50 files, this value would be 50. Before examining the first file, call setProgress(0); call setProgress(50) after examining the last file .

The parent, name and widget flags, f, are passed to the QFrame::QFrame() constructor.

See also totalSteps and progress.

bool QProgressBar::centerIndicator () const

Returns TRUE if the indicator string should be centered; otherwise returns FALSE. See the "centerIndicator" property for details.

bool QProgressBar::indicatorFollowsStyle () const

Returns TRUE if the display of the indicator string should follow the GUI style; otherwise returns FALSE. See the "indicatorFollowsStyle" property for details.

bool QProgressBar::percentageVisible () const

Returns TRUE if the current progress value is displayed; otherwise returns FALSE. See the "percentageVisible" property for details.

int QProgressBar::progress () const

Returns the current amount of progress. See the "progress" property for details.

constQString& QProgressBar::progressString () const

Returns the current amount of progress as a string. See the "progressString" property for details.

void QProgressBar::reset () [slot]

Reset the progress bar. The progress bar "rewinds" and shows no progress.

Examples: fileiconview/mainwindow.cpp, network/ftpclient/ftpmainwindow.cpp and progressbar/progressbar.cpp.

void QProgressBar::setCenterIndicator ( boolon )

Sets whether the indicator string should be centered to on. See the "centerIndicator" property for details.

bool QProgressBar::setIndicator ( QString&indicator, intprogress, inttotalSteps ) [virtual protected]

This method is called to generate the text displayed in the center (or in some styles, to the left) of the progress bar.

The progress may be negative, indicating that the progress bar is in the "reset" state before any progress is set.

The default implementation is the percentage of completion or blank in the reset state. The percentage is calculated based on the progress and totalSteps. You can set the indicator text if you wish.

To allow efficient repainting of the progress bar, this method should return FALSE if the string is unchanged from the last call to this function.

void QProgressBar::setIndicatorFollowsStyle ( bool )

Sets whether the display of the indicator string should follow the GUI style. See the "indicatorFollowsStyle" property for details.

void QProgressBar::setPercentageVisible ( bool )

Sets whether the current progress value is displayed. See the "percentageVisible" property for details.

void QProgressBar::setProgress ( intprogress ) [virtual slot]

Sets the current amount of progress to progress. See the "progress" property for details.

void QProgressBar::setTotalSteps ( inttotalSteps ) [virtual slot]

Sets the total number of steps to totalSteps. See the "totalSteps" property for details.

int QProgressBar::totalSteps () const

Returns the total number of steps. See the "totalSteps" property for details.


Property Documentation

bool centerIndicator

This property holds whether the indicator string should be centered.

Changing this property sets QProgressBar::indicatorFollowsStyle to FALSE. The default is TRUE.

Set this property's value with setCenterIndicator() and get this property's value with centerIndicator().

bool indicatorFollowsStyle

This property holds whether the display of the indicator string should follow the GUI style.

The default is TRUE.

See also centerIndicator.

Set this property's value with setIndicatorFollowsStyle() and get this property's value with indicatorFollowsStyle().

bool percentageVisible

This property holds whether the current progress value is displayed.

The default is TRUE.

See also centerIndicator and indicatorFollowsStyle.

Set this property's value with setPercentageVisible() and get this property's value with percentageVisible().

int progress

This property holds the current amount of progress.

This property is -1 if the progress counting has not started.

Set this property's value with setProgress() and get this property's value with progress().

QString progressString

This property holds the current amount of progress as a string.

This property is QString::null if the progress counting has not started.

Get this property's value with progressString().

int totalSteps

This property holds the total number of steps.

If totalSteps is null, the progress bar will display a busy indicator.

See also

Set this property's value with setTotalSteps() and get this property's value with totalSteps().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文