Q3ProgressBar Class

The Q3ProgressBar widget provides a horizontal progress bar. 更多...

头: #include <Q3ProgressBar>
继承: QFrame

特性

公共函数

Q3ProgressBar (QWidget * parent = 0, Qt::WindowFlags f = 0)
Q3ProgressBar (int totalSteps , QWidget * parent = 0, Qt::WindowFlags f = 0)
bool centerIndicator () const
int margin () const
bool percentageVisible () const
int progress () const
const QString & progressString () const
void setCenterIndicator (bool on )
void setMargin (int margin )
void setPercentageVisible (bool)
int totalSteps () const

重实现公共函数

virtual QSize minimumSizeHint () const
virtual void setVisible (bool visible )
virtual QSize sizeHint () const

公共槽

void reset ()
virtual void setProgress (int progress )
void setProgress (int progress , int totalSteps )
virtual void setTotalSteps (int totalSteps )

保护函数

virtual bool setIndicator (QString & indicator , int progress , int totalSteps )

重实现保护函数

virtual void changeEvent (QEvent * ev )
virtual void paintEvent (QPaintEvent *)

额外继承成员

详细描述

The Q3ProgressBar widget provides a horizontal progress bar.

进度条用于为用户给出操作进度指示,并安慰用户应用程序仍在运行。

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 ()。可以把进度条倒带到起始采用 reset ().

If the total is given as 0 the progress bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QHttp 下载项却无法确定要下载项的大小时。

Screenshot in Motif style Screenshot in Windows style

另请参阅 QProgressDialog and QProgressDialog .

特性文档编制

centerIndicator : bool

This property holds whether the indicator string should be centered.

访问函数:

bool centerIndicator () const
void setCenterIndicator (bool on )

percentageVisible : bool

This property holds whether the current progress value is displayed.

默认为 true。

访问函数:

bool percentageVisible () const
void setPercentageVisible (bool)

另请参阅 centerIndicator .

progress : int

This property holds the current amount of progress.

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

访问函数:

int progress () const
virtual void setProgress (int progress )
void setProgress (int progress , int totalSteps )

progressString : const QString

This property holds the amount of progress as a string.

This property is an empty string if progress counting has not started.

访问函数:

const QString & progressString () const

totalSteps : int

This property holds the total number of steps.

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

访问函数:

int totalSteps () const
virtual void setTotalSteps (int totalSteps )

成员函数文档编制

Q3ProgressBar:: Q3ProgressBar ( QWidget * parent = 0, Qt::WindowFlags f = 0)

Constructs a progress bar.

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

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

另请参阅 setTotalSteps ().

Q3ProgressBar:: Q3ProgressBar ( int totalSteps , QWidget * parent = 0, Qt::WindowFlags f = 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 , and widget flags, f , are passed to the QFrame::QFrame () constructor.

另请参阅 setTotalSteps () 和 setProgress ().

[virtual protected] void Q3ProgressBar:: changeEvent ( QEvent * ev )

重实现自 QWidget::changeEvent ().

int Q3ProgressBar:: margin () const

Returns the width of the margin around the contents of the widget.

此函数使用 QWidget::getContentsMargins () to get the margin.

该函数在 Qt 4.2 引入。

另请参阅 setMargin () 和 QWidget::getContentsMargins ().

[虚拟] QSize Q3ProgressBar:: minimumSizeHint () const

重实现自 QWidget::minimumSizeHint ().

[virtual protected] void Q3ProgressBar:: paintEvent ( QPaintEvent *)

重实现自 QWidget::paintEvent ().

[slot] void Q3ProgressBar:: reset ()

重置进度条。进度条倒带且不展示进度。

[virtual protected] bool Q3ProgressBar:: setIndicator ( QString & indicator , int progress , int totalSteps )

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 Q3ProgressBar:: setMargin ( int margin )

Sets the width of the margin around the contents of the widget to margin .

此函数使用 QWidget::setContentsMargins () to set the margin.

该函数在 Qt 4.2 引入。

另请参阅 margin () 和 QWidget::setContentsMargins ().

[虚拟] void Q3ProgressBar:: setVisible ( bool visible )

重实现自 QWidget::setVisible ().

[虚拟] QSize Q3ProgressBar:: sizeHint () const

重实现自 QWidget::sizeHint ().