The QProgressBar 小部件提供水平 (或垂直) 进度条。 更多...
| 头: | #include <QProgressBar> |
| 继承: | QWidget |
| enum | Direction { TopToBottom, BottomToTop } |
|
|
| QProgressBar (QWidget * parent = 0) | |
| Qt::Alignment | alignment () const |
| QString | format () const |
| bool | invertedAppearance () |
| bool | invertedAppearance () const |
| bool | isTextVisible () const |
| int | maximum () const |
| int | minimum () const |
| Qt::Orientation | orientation () const |
| 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 () |
| QProgressBar::Direction | textDirection () const |
| int | value () const |
| virtual QSize | minimumSizeHint () const |
| virtual QSize | sizeHint () const |
| 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 ) |
| void | initStyleOption (QStyleOptionProgressBar * option ) const |
| virtual bool | event (QEvent * e ) |
| virtual void | paintEvent (QPaintEvent *) |
The QProgressBar 小部件提供水平 (或垂直) 进度条。
进度条用于为用户给出操作进度指示,并安慰用户应用程序仍在运行。
The progress bar uses the concept of steps . You set it up by specifying the minimum and maximum possible step values, and it will display the percentage of steps that have been completed when you later give it the current step value. The percentage is calculated by dividing the progress ( value () - minimum ()) 除以 maximum () - minimum ().
可以指定最小和最大步幅数采用 setMinimum () 和 setMaximum 。设置当前步幅数采用 setValue ()。可以把进度条倒带到起始采用 reset ().
若把最小和最大两者设为 0,条展示繁忙指示器,而不是步进百分比。这很有用,例如,当使用 QFtp or QNetworkAccessManager 下载项却无法确定要下载项的大小时。
|
A progress bar shown in the Macintosh widget style. |
|
A progress bar shown in the Windows XP widget style. |
|
A progress bar shown in the Plastique widget style. |
另请参阅 QProgressDialog and GUI 设计手册:进度指示器 .
指定阅读方向为 text 为垂直进度条。
| 常量 | 值 | 描述 |
|---|---|---|
QProgressBar::TopToBottom
|
0
|
文本被顺时针旋转 90 度。 |
QProgressBar::BottomToTop
|
1
|
文本被逆时针旋转 90 度。 |
Note that whether or not the text is drawn is dependent on the style. Currently CDE, CleanLooks, Motif, and Plastique draw the text. Mac, Windows and WindowsXP style do not.
该枚举在 Qt 4.1 引入或被修改。
另请参阅 textDirection .
This property holds the alignment of the progress bar.
访问函数:
| Qt::Alignment | alignment () const |
| void | setAlignment (Qt::Alignment alignment ) |
This property holds the string used to generate the current text.
%p - 由完成百分比替换。%v - 由当前值替换。%m - 由总步数替换。
默认值为 "%p%"。
该特性在 Qt 4.2 引入。
访问函数:
| QString | format () const |
| void | setFormat (const QString & format ) |
另请参阅 text ().
This property holds whether or not a progress bar shows its progress inverted.
If this property is false, the progress bar grows in the other direction (e.g. from right to left). By default, the progress bar is not inverted.
该特性在 Qt 4.1 引入。
访问函数:
| bool | invertedAppearance () |
| bool | invertedAppearance () const |
| void | setInvertedAppearance (bool invert ) |
另请参阅 orientation and layoutDirection .
This property holds the progress bar's maximum value.
当设置此特性时, minimum 被调节,若有必要,确保范围仍然有效。若当前值落在新范围外,重置进度条采用 reset ().
访问函数:
| int | maximum () const |
| void | setMaximum (int maximum ) |
This property holds the progress bar's minimum value.
当设置此特性时, maximum 被调节,若有必要,确保范围仍然有效。若当前值落在新范围外,重置进度条采用 reset ().
访问函数:
| int | minimum () const |
| void | setMinimum (int minimum ) |
This property holds the orientation of the progress bar.
取向必须是 Qt::Horizontal (默认) 或 Qt::Vertical .
该特性在 Qt 4.1 引入。
访问函数:
| Qt::Orientation | orientation () const |
| void | setOrientation (Qt::Orientation) |
另请参阅 invertedAppearance and textDirection .
This property holds the descriptive text shown with the progress bar.
返回文本同进度条居中 (或某些风格左侧) 显示文本。
文本中显示进度可能小于最小值,指示进度条处于重置状态,在任何进度被设置之前。
在默认实现中,文本包含指示到目前为止的进度百分比值,或为空 (因为进度条处于重置状态)。
访问函数:
| virtual QString | text () const |
This property holds the reading direction of the text for vertical progress bars.
此特性对水平进度条没有影响。默认情况下,读取方向为 QProgressBar::TopToBottom .
该特性在 Qt 4.1 引入。
访问函数:
| QProgressBar::Direction | textDirection () |
| QProgressBar::Direction | textDirection () const |
| void | setTextDirection (QProgressBar::Direction textDirection ) |
另请参阅 orientation and textVisible .
This property holds whether the current completed percentage should be displayed.
This property may be ignored by the style (e.g., QMacStyle never draws the text).
访问函数:
| bool | isTextVisible () const |
| void | setTextVisible (bool visible ) |
另请参阅 textDirection .
This property holds the progress bar's current value.
试图把当前值更改为最小-最大范围之外的某一值,不影响当前值。
访问函数:
| int | value () const |
| void | setValue (int value ) |
通知程序信号:
| void | valueChanged (int value ) |
构造进度条采用给定 parent .
默认情况下,最小步幅值被设为 0,而最大为 100。
另请参阅 setRange ().
[virtual protected]
bool
QProgressBar::
event
(
QEvent
*
e
)
重实现自 QObject::event ().
[protected]
void
QProgressBar::
initStyleOption
(
QStyleOptionProgressBar
*
option
) const
初始化 option 采用值来自此 QProgressBar 。此方法对子类是有用的,当需要 QStyleOptionProgressBar or QStyleOptionProgressBarV2 , but don't want to fill in all the information themselves. This function will check the version of the QStyleOptionProgressBar and fill in the additional values for a QStyleOptionProgressBarV2 .
另请参阅 QStyleOption::initFrom ().
[虚拟]
QSize
QProgressBar::
minimumSizeHint
() const
重实现自 QWidget::minimumSizeHint ().
[virtual protected]
void
QProgressBar::
paintEvent
(
QPaintEvent
*)
重实现自 QWidget::paintEvent ().
[slot]
void
QProgressBar::
reset
()
重置进度条。进度条倒带且不展示进度。
[slot]
void
QProgressBar::
setRange
(
int
minimum
,
int
maximum
)
把进度条的最小和最大值设为 minimum and maximum 分别。
若 maximum 小于 minimum , minimum 变为唯一合法值。
若当前值落在新范围之外,进度条被重置采用 reset ().
[虚拟]
QSize
QProgressBar::
sizeHint
() const
重实现自 QWidget::sizeHint ().