QProgressBar 小部件提供水平 (或垂直) 进度条。 更多...
头: | #include <QProgressBar> |
qmake: | QT += widgets |
继承: | QWidget |
enum | Direction { TopToBottom, BottomToTop } |
|
|
QProgressBar (QWidget * parent = Q_NULLPTR) | |
~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 |
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 * ) |
QProgressBar 小部件提供水平 (或垂直) 进度条。
进度条用于为用户给出操作进度指示,并安慰用户应用程序仍在运行。
进度条使用 steps 概念。通过指定最小和最大可能步进值设置,它将显示已完成的步进百分比,当稍后给予当前步进值时。百分比的计算是通过进度 ( value () - minimum ()) 除以 maximum () - minimum ().
可以指定最小和最大步进数采用 setMinimum () 和 setMaximum 。设置当前步进数采用 setValue ()。可以把进度条倒带到起始采用 reset ().
若把最小和最大两者设为 0,条展示繁忙指示器,而不是步进百分比。这很有用,例如,当使用 QNetworkAccessManager 下载项却无法确定要下载项的大小时。
另请参阅 QProgressDialog and GUI 设计手册:进度指示器 .
指定阅读方向为 text 为垂直进度条。
常量 | 值 | 描述 |
---|---|---|
QProgressBar::TopToBottom
|
0
|
文本被顺时针旋转 90 度。 |
QProgressBar::BottomToTop
|
1
|
文本被逆时针旋转 90 度。 |
注意,是否绘制文本从属样式。目前 CleanLooks 和 Plastique 绘制文本。Mac、Windows 和 WindowsXP 样式不绘制。
该枚举在 Qt 4.1 引入或被修改。
另请参阅 textDirection .
此特性保持进度条的对齐
访问函数:
Qt::Alignment | alignment () const |
void | setAlignment (Qt::Alignment alignment ) |
此特性保持用于生成当前文本的字符串
%p - 由完成百分比替换。%v - 由当前值替换。%m - 由总步数替换。
默认值为 "%p%"。
该特性在 Qt 4.2 引入。
访问函数:
QString | format () const |
void | setFormat (const QString & format ) |
void | resetFormat () |
另请参阅 text ().
此特性保持进度条是否展示其进度的反转
若此特性为
true
,进度条朝另一方向 (如:从右到左) 增长。默认情况下,进度条不反转。
该特性在 Qt 4.1 引入。
访问函数:
bool | invertedAppearance () const |
void | setInvertedAppearance (bool invert ) |
另请参阅 orientation and layoutDirection .
此特性保持进度条的最大值
当设置此特性时, minimum 被调节,若有必要确保范围仍然有效。若当前值落在新范围之外,进度条被重置采用 reset ().
访问函数:
int | maximum () const |
void | setMaximum (int maximum ) |
此特性保持进度条的最小值
当设置此特性时, maximum 被调节,若有必要确保范围仍然有效。若当前值落在新范围之外,进度条被重置采用 reset ().
访问函数:
int | minimum () const |
void | setMinimum (int minimum ) |
此特性保持进度条的方向
取向必须是 Qt::Horizontal (默认) 或 Qt::Vertical .
该特性在 Qt 4.1 引入。
访问函数:
Qt::Orientation | orientation () const |
void | setOrientation ( Qt::Orientation ) |
另请参阅 invertedAppearance and textDirection .
此特性保持采用进度条展示的描述性文本
返回文本同进度条居中 (或某些风格左侧) 显示文本。
文本中显示进度可能小于最小值,指示进度条处于重置状态,在任何进度被设置之前。
在默认实现中,文本包含指示到目前为止的进度百分比值,或为空 (因为进度条处于重置状态)。
访问函数:
virtual QString | text () const |
此特性保持阅读方向为 text 为垂直进度条
此特性对水平进度条没有影响。默认情况下,读取方向为 QProgressBar::TopToBottom .
该特性在 Qt 4.1 引入。
访问函数:
QProgressBar::Direction | textDirection () const |
void | setTextDirection (QProgressBar::Direction textDirection ) |
另请参阅 orientation and textVisible .
此特性保持是否应显示当前已完成的百分比
此特性可能被样式忽略 (如:QMacStyle 从不绘制文本)。
访问函数:
bool | isTextVisible () const |
void | setTextVisible (bool visible ) |
另请参阅 textDirection .
此特性保持进度条的当前值
试图把当前值更改为最小-最大范围之外的某一值,不影响当前值。
访问函数:
int | 值 () 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 ,但不希望自己填充所有信息。
另请参阅 QStyleOption::initFrom ().
[virtual]
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 ().
QProgressBar 可以被设为不确定状态通过使用 setRange(0, 0)。
[virtual]
QSize
QProgressBar::
sizeHint
() const
重实现自 QWidget::sizeHint ().
[signal]
void
QProgressBar::
valueChanged
(
int
value
)
此信号被发射当进度条展示值改变时。 value 是由进度条展示的新值。
注意: 通知程序信号对于特性 value .