|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.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
public class QDialogButtonBox
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:
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.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 |
![]() | 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 |
ActionRole
or HelpRole
can be considered modeless and have an alternate look on the mac: ![]() | modeless horizontal MacLayout |
![]() | modeless vertical MacLayout |
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,
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.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 |
---|
public final QSignalEmitter.Signal0 accepted
AcceptRole
or YesRole
. rejected()
, clicked()
, and helpRequested()
.
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.
accepted()
, rejected()
, and helpRequested()
.
public final QSignalEmitter.Signal0 helpRequested
HelpRole
. accepted()
, rejected()
, and clicked()
.
public final QSignalEmitter.Signal0 rejected
RejectRole
or NoRole
. accepted()
, helpRequested()
, and clicked()
.
Constructor Detail |
---|
public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons, Qt.Orientation orientation)
orientation
, and addButton()
.
public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons)
orientation
, and addButton()
.
public QDialogButtonBox(QDialogButtonBox.StandardButtons buttons, Qt.Orientation orientation, QWidget parent)
orientation
, and addButton()
.
public QDialogButtonBox()
orientation
, and addButton()
.
public QDialogButtonBox(QWidget parent)
orientation
, and addButton()
.
public QDialogButtonBox(Qt.Orientation orientation)
orientation
, and addButton()
.
public QDialogButtonBox(Qt.Orientation orientation, QWidget parent)
orientation
, and addButton()
.
Method Detail |
---|
public final void addButton(QAbstractButton button, QDialogButtonBox.ButtonRole role)
If the button has already been added, it is removed and added again with the new role.
removeButton()
, and clear()
.
public final QPushButton addButton(QDialogButtonBox.StandardButton button)
removeButton()
, and clear()
.
public final QPushButton addButton(java.lang.String text, QDialogButtonBox.ButtonRole role)
removeButton()
, and clear()
.
public final QPushButton button(QDialogButtonBox.StandardButton which)
QPushButton
corresponding to the standard button which, or 0 if the standard button doesn't exist in this button box. standardButton()
, standardButtons()
, and buttons()
.
public final QDialogButtonBox.ButtonRole buttonRole(QAbstractButton button)
InvalidRole
if button is 0 or has not been added to the button box. buttons()
, and addButton()
.
public final java.util.List buttons()
buttonRole()
, addButton()
, and removeButton()
.
public final boolean centerButtons()
QMessageBox
.
public final void clear()
removeButton()
, and addButton()
.
public final Qt.Orientation orientation()
Qt::Horizontal
and Qt::Vertical
.
public final void removeButton(QAbstractButton button)
clear()
, buttons()
, and addButton()
.
public final void setCenterButtons(boolean center)
QMessageBox
.
public final void setOrientation(Qt.Orientation orientation)
Qt::Horizontal
and Qt::Vertical
.
public final void setStandardButtons(QDialogButtonBox.StandardButton[] buttons)
addButton()
.
public final void setStandardButtons(QDialogButtonBox.StandardButtons buttons)
addButton()
.
public final QDialogButtonBox.StandardButton standardButton(QAbstractButton button)
NoButton
if the given button isn't a standard button. button()
, buttons()
, and standardButtons()
.
public final QDialogButtonBox.StandardButtons standardButtons()
addButton()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |