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 ().