Qt Jambi Home

com.trolltech.qt.gui
Class QProgressBar

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QProgressBar
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QProgressBar
extends QWidget

The QProgressBar widget provides a horizontal or vertical 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 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) divided by maximum - minimum.

You can specify the minimum and maximum number of steps with setMinimum and setMaximum. The current number of steps is set with setValue. The progress bar can be rewound to the beginning with reset.

If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QFtp or QHttp to download items when they are unable to determine the size of the item being downloaded.

Screenshot of a Macintosh style progress barA progress bar shown in the Macintosh widget style.
Screenshot of a Windows XP style progress barA progress bar shown in the Windows XP widget style.
Screenshot of a Plastique style progress barA progress bar shown in the Plastique widget style.

See Also:
QTimeLine, QProgressDialog, GUI Design Handbook: Progress Indicator

Nested Class Summary
static class QProgressBar.Direction
          Specifies the reading direction of the text for vertical progress bars.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<java.lang.Integer> valueChanged
          This signal is emitted when the value shown in the progress bar changes.
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QProgressBar()
          Equivalent to QProgressBar(0).
QProgressBar(QWidget parent)
          Constructs a progress bar with the given parent.
 
Method Summary
 Qt.Alignment alignment()
          Returns the alignment of the progress bar.
 boolean event(QEvent e)
          

This is the main event handler; it handles event arg__1.

 java.lang.String format()
          Returns the string used to generate the current text.
static QProgressBar fromNativePointer(QNativePointer nativePointer)
          This function returns the QProgressBar instance pointed to by nativePointer
protected  void initStyleOption(QStyleOptionProgressBar option)
          Initialize option with the values from this QProgressBar.
 boolean invertedAppearance()
          Returns whether or not a progress bar shows its progress inverted.
 boolean isTextVisible()
          Returns whether the current completed percentage should be displayed.
 int maximum()
          Returns the progress bar's maximum value.
 int minimum()
          Returns the progress bar's minimum value.
 QSize minimumSizeHint()
          

Returns the recommended minimum size for the widget.

 Qt.Orientation orientation()
          Returns the orientation of the progress bar.
protected  void paintEvent(QPaintEvent arg__1)
          

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

 void reset()
          Reset the progress bar.
 void setAlignment(Qt.Alignment alignment)
          Sets the alignment of the progress bar to alignment.
 void setAlignment(Qt.AlignmentFlag... alignment)
          Sets the alignment of the progress bar to alignment.
 void setFormat(java.lang.String format)
          Sets the string used to generate the current text to format.
 void setInvertedAppearance(boolean invert)
          Sets whether or not a progress bar shows its progress inverted to invert.
 void setMaximum(int maximum)
          Sets the progress bar's maximum value to maximum.
 void setMinimum(int minimum)
          Sets the progress bar's minimum value to minimum.
 void setOrientation(Qt.Orientation arg__1)
          Sets the orientation of the progress bar to arg__1.
 void setRange(int minimum, int maximum)
          Sets the progress bar's minimum and maximum values to minimum and maximum respectively.
 void setTextDirection(QProgressBar.Direction textDirection)
          Sets the reading direction of the text for vertical progress bars to textDirection.
 void setTextVisible(boolean visible)
          Sets whether the current completed percentage should be displayed to visible.
 void setValue(int value)
          Sets the progress bar's current value to value.
 QSize sizeHint()
          

Returns the recommended size for the widget.

 java.lang.String text()
          Returns the descriptive text shown with the progress bar.
 QProgressBar.Direction textDirection()
          Returns the reading direction of the text for vertical progress bars.
 int value()
          Returns the progress bar's current value.
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

valueChanged

public final QSignalEmitter.Signal1<java.lang.Integer> valueChanged

This signal is emitted when the value shown in the progress bar changes. value is the new value shown by the progress bar.

Compatible Slot Signatures:
void mySlot(int value)
void mySlot()

Constructor Detail

QProgressBar

public QProgressBar()

Equivalent to QProgressBar(0).


QProgressBar

public QProgressBar(QWidget parent)

Constructs a progress bar with the given parent.

By default, the minimum step value is set to 0, and the maximum to 100.

See Also:
setRange
Method Detail

alignment

public final Qt.Alignment alignment()

Returns the alignment of the progress bar.

See Also:
setAlignment

format

public final java.lang.String format()

Returns the string used to generate the current text.

%p - is replaced by the percentage completed. %v - is replaced by the current value. %m - is replaced by the total number of steps.

The default value is "%p%".

See Also:
setFormat, text

invertedAppearance

public final boolean invertedAppearance()

Returns 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.

See Also:
setInvertedAppearance, orientation, layoutDirection

isTextVisible

public final boolean isTextVisible()

Returns whether the current completed percentage should be displayed.

See Also:
textDirection

maximum

public final int maximum()

Returns the progress bar's maximum value.

When setting this property, the minimum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset.

See Also:
setMaximum

minimum

public final int minimum()

Returns the progress bar's minimum value.

When setting this property, the maximum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset.

See Also:
setMinimum

orientation

public final Qt.Orientation orientation()

Returns the orientation of the progress bar.

The orientation must be Qt::Horizontal (the default) or Qt::Vertical.

See Also:
setOrientation, invertedAppearance, textDirection

reset

public final void reset()

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


setAlignment

public final void setAlignment(Qt.AlignmentFlag... alignment)

Sets the alignment of the progress bar to alignment.

See Also:
alignment

setAlignment

public final void setAlignment(Qt.Alignment alignment)

Sets the alignment of the progress bar to alignment.

See Also:
alignment

setFormat

public final void setFormat(java.lang.String format)

Sets the string used to generate the current text to format.

%p - is replaced by the percentage completed. %v - is replaced by the current value. %m - is replaced by the total number of steps.

The default value is "%p%".

See Also:
format, text

setInvertedAppearance

public final void setInvertedAppearance(boolean invert)

Sets whether or not a progress bar shows its progress inverted to invert.

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.

See Also:
invertedAppearance, orientation, layoutDirection

setMaximum

public final void setMaximum(int maximum)

Sets the progress bar's maximum value to maximum.

When setting this property, the minimum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset.

See Also:
maximum

setMinimum

public final void setMinimum(int minimum)

Sets the progress bar's minimum value to minimum.

When setting this property, the maximum is adjusted if necessary to ensure that the range remains valid. If the current value falls outside the new range, the progress bar is reset with reset.

See Also:
minimum

setOrientation

public final void setOrientation(Qt.Orientation arg__1)

Sets the orientation of the progress bar to arg__1.

The orientation must be Qt::Horizontal (the default) or Qt::Vertical.

See Also:
orientation, invertedAppearance, textDirection

setRange

public final void setRange(int minimum,
                           int maximum)

Sets the progress bar's minimum and maximum values to minimum and maximum respectively.

If maximum is smaller than minimum, minimum becomes the only legal value.

If the current value falls outside the new range, the progress bar is reset with reset.

See Also:
minimum, maximum

setTextDirection

public final void setTextDirection(QProgressBar.Direction textDirection)

Sets the reading direction of the text for vertical progress bars to textDirection.

This property has no impact on horizontal progress bars. By default, the reading direction is QProgressBar::TopToBottom.

See Also:
textDirection, orientation, textVisible

setTextVisible

public final void setTextVisible(boolean visible)

Sets whether the current completed percentage should be displayed to visible.

See Also:
isTextVisible, textDirection

setValue

public final void setValue(int value)

Sets the progress bar's current value to value.

Attempting to change the current value to one outside the minimum-maximum range has no effect on the current value.

See Also:
value

textDirection

public final QProgressBar.Direction textDirection()

Returns the reading direction of the text for vertical progress bars.

This property has no impact on horizontal progress bars. By default, the reading direction is QProgressBar::TopToBottom.

See Also:
setTextDirection, orientation, textVisible

value

public final int value()

Returns the progress bar's current value.

Attempting to change the current value to one outside the minimum-maximum range has no effect on the current value.

See Also:
setValue

event

public boolean event(QEvent e)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QWidget
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

minimumSizeHint

public QSize minimumSizeHint()

Returns the recommended minimum size for the widget.

If the value of this property is an invalid size, no minimum size is recommended.

The default implementation of minimumSizeHint returns an invalid size if there is no layout for this widget, and returns the layout's minimum size otherwise. Most built-in widgets reimplement minimumSizeHint.

QLayout will never resize a widget to a size smaller than the minimum size hint unless minimumSize is set or the size policy is set to QSizePolicy::Ignore. If minimumSize is set, the minimum size hint will be ignored.

Overrides:
minimumSizeHint in class QWidget
See Also:
QSize::isValid, resize, setMinimumSize, sizePolicy

paintEvent

protected void paintEvent(QPaintEvent arg__1)

This event handler can be reimplemented in a subclass to receive paint events which are passed in the arg__1 parameter.

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint or update, or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QTableView do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::united()). repaint does not permit this optimization, so we suggest using update whenever possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background.

The background can be set using setBackgroundRole and setPalette.

From Qt 4.0, QWidget automatically double-buffers its painting, so there's no need to write double-buffering code in paintEvent to avoid flicker.

Note: Under X11 it is possible to toggle the global double buffering by calling qt_x11_set_global_double_buffer(). Example usage:

    ...
    extern void qt_x11_set_global_double_buffer(bool);
    qt_x11_set_global_double_buffer(false);
    ...

Note: In general, one should refrain from calling update or repaint inside of paintEvent. For example, calling update or repaint on children inside a paintEvent results in undefined behavior; the child may or may not get a paint event.

Overrides:
paintEvent in class QWidget
See Also:
event, repaint, update, QPainter, QPixmap, QPaintEvent, Analog Clock Example

sizeHint

public QSize sizeHint()

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

Overrides:
sizeHint in class QWidget
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

text

public java.lang.String text()

Returns the descriptive text shown with the progress bar.

The text returned is the same as the text displayed in the center (or in some styles, to the left) of the progress bar.

The progress shown in the text may be smaller than the minimum value, indicating that the progress bar is in the "reset" state before any progress is set.

In the default implementation, the text either contains a percentage value that indicates the progress so far, or it is blank because the progress bar is in the reset state.


fromNativePointer

public static QProgressBar fromNativePointer(QNativePointer nativePointer)
This function returns the QProgressBar instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

initStyleOption

protected final void initStyleOption(QStyleOptionProgressBar option)
Initialize option with the values from this QProgressBar. This method is useful for subclasses when they need a 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.


Qt Jambi Home