Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QDialogButtonBox

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QDialogButtonBox

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QDialogButtonBox

extends QWidget

The `QDialogButtonBox` class is a widget that presents buttons in a layout that is appropriate to the current widget style. Dialogs and message boxes typically present buttons in a layout that conforms to the interface guidelines for that platform. Invariably, different platforms have different layouts for their dialogs. `QDialogButtonBox` allows a developer to add buttons to it and will automatically use the appropriate layout for the user's desktop environment.

Most buttons for a dialog follow certain roles. Such roles include:

- Accepting or rejecting the dialog.
- Asking for help.
- Performing actions on the dialog itself (such as resetting fields or applying changes).

There can also be alternate ways of dismissing the dialog which may cause destructive results.

Most dialogs have buttons that can almost be considered standard (e.g. OK and Cancel buttons). It is sometimes convenient to create these buttons in a standard way.

There are a couple ways of using `QDialogButtonBox`. One ways is to create the buttons (or button texts) yourself and add them to the button box, specifying their role.
The following code example is written in c++.

        findButton = new QPushButton(tr("&Find"));
        findButton->setDefault(true);

        moreButton = new QPushButton(tr("&More"));
        moreButton->setCheckable(true);

        moreButton->setAutoDefault(false);

        buttonBox = new QDialogButtonBox(Qt::Vertical);
        buttonBox->addButton(findButton, QDialogButtonBox::ActionRole);
        buttonBox->addButton(moreButton, QDialogButtonBox::ActionRole);

Alternatively, `QDialogButtonBox` provides several standard buttons (e.g. OK, Cancel, Save) that you can use. They exist as flags so you can OR them together in the constructor.
The following code example is written in c++.

        buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok

                                         | QDialogButtonBox::Cancel);

        connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
        connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

You can mix and match normal buttons and standard buttons.

Currently the buttons are laid out in the following way if the button box is horizontal:

| Button box laid out in horizontal `GnomeLayout`
| Button box laid out in horizontal `KdeLayout`
| Button box laid out in horizontal `MacLayout`
| Button box laid out in horizontal `WinLayout`

The buttons are laid out the following way if the button box is vertical:

| Button box laid out in vertical `GnomeLayout`
| Button box laid out in vertical `KdeLayout`
| Button box laid out in vertical `MacLayout`
| Button box laid out in vertical `WinLayout`

Additionally, button boxes that contain only buttons with `ActionRole` or `HelpRole` can be considered modeless and have an alternate look on the mac:

| modeless horizontal `MacLayout`
| modeless vertical `MacLayout`

When a button is clicked in the button box, the `clicked()` signal is emitted for the actual button is that is pressed. For convenience, if the button has an `AcceptRole` , `RejectRole` , or `HelpRole` , the `accepted()` , `rejected()` , or `helpRequested()` signals are emitted respectively.

If you want a specific button to be default you need to call `QPushButton::setDefault()` on it yourself. However, if there is no default button set and to preserve which button is the default button across platforms when using the `QPushButton::autoDefault` property, the first push button with the accept role is made the default button when the `QDialogButtonBox` is shown,

See also:
  `QMessageBox`, `QPushButton`, and `QDialog`.

Nested Class Summary
`static class` | `QDialogButtonBox.ButtonLayout` This enum describes the layout policy to be used when arranging the buttons contained in the button box.
`static class` | `QDialogButtonBox.ButtonRole` This enum describes the roles that can be used to describe buttons in the button box.
`static class` | `QDialogButtonBox.StandardButton` These enums describe flags for standard buttons.
`static class` | `QDialogButtonBox.StandardButtons` This is a flags class for com.trolltech.qt.gui.QDialogButtonBox.StandardButton

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.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal0` | `accepted` This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `AcceptRole` or `YesRole` .
`QSignalEmitter.Signal1` | `clicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal0` | `helpRequested` This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `HelpRole` .
`QSignalEmitter.Signal0` | `rejected` This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `RejectRole` or `NoRole` .

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QDialogButtonBox()` Constructs an empty, horizontal button box with the given `parent`.
`QDialogButtonBox(QDialogButtonBox.StandardButtons buttons)` Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.
`QDialogButtonBox(QDialogButtonBox.StandardButtons buttons, Qt.Orientation orientation)` Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.
`QDialogButtonBox(QDialogButtonBox.StandardButtons buttons, Qt.Orientation orientation, QWidget parent)` Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.
`QDialogButtonBox(Qt.Orientation orientation)` Constructs an empty button box with the given `orientation` and `parent`.
`QDialogButtonBox(Qt.Orientation orientation, QWidget parent)` Constructs an empty button box with the given `orientation` and `parent`.
`QDialogButtonBox(QWidget parent)` Constructs an empty, horizontal button box with the given `parent`.

Method Summary
`void` | `addButton(QAbstractButton button, QDialogButtonBox.ButtonRole role)` Adds the given `button` to the button box with the specified `role`.
`QPushButton` | `addButton(QDialogButtonBox.StandardButton button)` Adds a standard `button` to the button box if it is valid to do so, and returns a push button.
`QPushButton` | `addButton(java.lang.String text, QDialogButtonBox.ButtonRole role)` Creates a push button with the given `text`, adds it to the button box for the specified `role`, and returns the corresponding push button.
`QPushButton` | `button(QDialogButtonBox.StandardButton which)` Returns the `QPushButton` corresponding to the standard button `which`, or 0 if the standard button doesn't exist in this button box.
`QDialogButtonBox.ButtonRole` | `buttonRole(QAbstractButton button)` Returns the button role for the specified `button`.
`java.util.List` | `buttons()` Returns a list of all the buttons that have been added to the button box.
`boolean` | `centerButtons()` This property holds whether the buttons in the button box are centered.
`void` | `clear()` Clears the button box, deleting all buttons within it.
`Qt.Orientation` | `orientation()` This property holds the orientation of the button box.
`void` | `removeButton(QAbstractButton button)` Removes `button` from the button box without deleting it and sets its parent to zero.
`void` | `setCenterButtons(boolean center)` This property holds whether the buttons in the button box are centered.
`void` | `setOrientation(Qt.Orientation orientation)` This property holds the orientation of the button box.
`void` | `setStandardButtons(QDialogButtonBox.StandardButton[] buttons)` This property holds collection of standard buttons in the button box.
`void` | `setStandardButtons(QDialogButtonBox.StandardButtons buttons)` This property holds collection of standard buttons in the button box.
`QDialogButtonBox.StandardButton` | `standardButton(QAbstractButton button)` Returns the standard button enum value corresponding to the given `button`, or `NoButton` if the given `button` isn't a standard button.
`QDialogButtonBox.StandardButtons` | `standardButtons()` This property holds collection of standard buttons in the button box.

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, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, 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, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, 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, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, 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, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### accepted

    public final QSignalEmitter.Signal0 accepted

  This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `AcceptRole` or `YesRole` .

See also:
  `rejected()` , `clicked()` , and `helpRequested()` .

### clicked

    public final QSignalEmitter.Signal1 clicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QAbstractButton(named: button)>:

  This signal is emitted when a button inside the button box is clicked. The specific button that was pressed is specified by `button`.

See also:
  `accepted()` , `rejected()` , and `helpRequested()` .

### helpRequested

    public final QSignalEmitter.Signal0 helpRequested

  This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `HelpRole` .

See also:
  `accepted()` , `rejected()` , and `clicked()` .

### rejected

    public final QSignalEmitter.Signal0 rejected

  This signal is emitted when a button inside the button box is clicked, as long as it was defined with the `RejectRole` or `NoRole` .

See also:
  `accepted()` , `helpRequested()` , and `clicked()` .

Constructor Detail

### QDialogButtonBox

    public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons,
                            Qt.Orientation orientation)

  Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons)

  Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons,
                            Qt.Orientation orientation,
                            QWidget parent)

  Constructs a button box with the given `orientation` and `parent`, containing the standard buttons specified by `buttons`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox()

  Constructs an empty, horizontal button box with the given `parent`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox(QWidget parent)

  Constructs an empty, horizontal button box with the given `parent`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox(Qt.Orientation orientation)

  Constructs an empty button box with the given `orientation` and `parent`.

See also:
  `orientation`, and `addButton()`.

### QDialogButtonBox

    public QDialogButtonBox(Qt.Orientation orientation,
                            QWidget parent)

  Constructs an empty button box with the given `orientation` and `parent`.

See also:
  `orientation`, and `addButton()`.

Method Detail

### addButton

    public final void addButton(QAbstractButton button,
                                QDialogButtonBox.ButtonRole role)

  Adds the given `button` to the button box with the specified `role`. If the role is invalid, the button is not added.

  If the button has already been added, it is removed and added again with the new role.

See also:
  `removeButton()`, and `clear()`.

### addButton

    public final QPushButton addButton(QDialogButtonBox.StandardButton button)

  Adds a standard `button` to the button box if it is valid to do so, and returns a push button. If `button` is invalid, it is not added to the button box, and zero is returned.

See also:
  `removeButton()`, and `clear()`.

### addButton

    public final QPushButton addButton(java.lang.String text,
                                       QDialogButtonBox.ButtonRole role)

  Creates a push button with the given `text`, adds it to the button box for the specified `role`, and returns the corresponding push button. If `role` is invalid, no button is created, and zero is returned.

See also:
  `removeButton()`, and `clear()`.

### button

    public final QPushButton button(QDialogButtonBox.StandardButton which)

  Returns the `QPushButton` corresponding to the standard button `which`, or 0 if the standard button doesn't exist in this button box.

See also:
  `standardButton()`, `standardButtons()`, and `buttons()`.

### buttonRole

    public final QDialogButtonBox.ButtonRole buttonRole(QAbstractButton button)

  Returns the button role for the specified `button`. This function returns `InvalidRole` if `button` is 0 or has not been added to the button box.

See also:
  `buttons()`, and `addButton()`.

### buttons

    public final java.util.List buttons()

  Returns a list of all the buttons that have been added to the button box.

See also:
  `buttonRole()`, `addButton()`, and `removeButton()`.

### centerButtons

    public final boolean centerButtons()

  This property holds whether the buttons in the button box are centered. By default, this property is false. This behavior is appopriate for most types of dialogs. A notable exception is message boxes on most platforms (e.g. Windows), where the button box is centered horizontally.

See also:
  `QMessageBox`.

### clear

    public final void clear()

  Clears the button box, deleting all buttons within it.

See also:
  `removeButton()`, and `addButton()`.

### orientation

    public final Qt.Orientation orientation()

  This property holds the orientation of the button box. By default, the orientation is horizontal (i.e. the buttons are laid out side by side). The possible orientations are `Qt::Horizontal` and `Qt::Vertical` .

### removeButton

    public final void removeButton(QAbstractButton button)

  Removes `button` from the button box without deleting it and sets its parent to zero.

See also:
  `clear()`, `buttons()`, and `addButton()`.

### setCenterButtons

    public final void setCenterButtons(boolean center)

  This property holds whether the buttons in the button box are centered. By default, this property is false. This behavior is appopriate for most types of dialogs. A notable exception is message boxes on most platforms (e.g. Windows), where the button box is centered horizontally.

See also:
  `QMessageBox`.

### setOrientation

    public final void setOrientation(Qt.Orientation orientation)

  This property holds the orientation of the button box. By default, the orientation is horizontal (i.e. the buttons are laid out side by side). The possible orientations are `Qt::Horizontal` and `Qt::Vertical` .

### setStandardButtons

    public final void setStandardButtons(QDialogButtonBox.StandardButton[] buttons)

  This property holds collection of standard buttons in the button box. This property controls which standard buttons are used by the button box.

See also:
  `addButton()`.

### setStandardButtons

    public final void setStandardButtons(QDialogButtonBox.StandardButtons buttons)

  This property holds collection of standard buttons in the button box. This property controls which standard buttons are used by the button box.

See also:
  `addButton()`.

### standardButton

    public final QDialogButtonBox.StandardButton standardButton(QAbstractButton button)

  Returns the standard button enum value corresponding to the given `button`, or `NoButton` if the given `button` isn't a standard button.

See also:
  `button()`, `buttons()`, and `standardButtons()`.

### standardButtons

    public final QDialogButtonBox.StandardButtons standardButtons()

  This property holds collection of standard buttons in the button box. This property controls which standard buttons are used by the button box.

See also:
  `addButton()`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD