Qt 4.8
Public Types | Signals | Public Functions | Protected Functions | Properties | List of all members
QDialogButtonBox Class Reference

The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the current widget style. More...

#include <qdialogbuttonbox.h>

Inheritance diagram for QDialogButtonBox:
QWidget QObject QPaintDevice

Public Types

enum  ButtonLayout { WinLayout, MacLayout, KdeLayout, GnomeLayout }
 This enum describes the layout policy to be used when arranging the buttons contained in the button box. More...
 
enum  ButtonRole {
  InvalidRole = -1, AcceptRole, RejectRole, DestructiveRole,
  ActionRole, HelpRole, YesRole, NoRole,
  ResetRole, ApplyRole, NRoles
}
 This enum describes the roles that can be used to describe buttons in the button box. More...
 
enum  StandardButton {
  NoButton = 0x00000000, Ok = 0x00000400, Save = 0x00000800, SaveAll = 0x00001000,
  Open = 0x00002000, Yes = 0x00004000, YesToAll = 0x00008000, No = 0x00010000,
  NoToAll = 0x00020000, Abort = 0x00040000, Retry = 0x00080000, Ignore = 0x00100000,
  Close = 0x00200000, Cancel = 0x00400000, Discard = 0x00800000, Help = 0x01000000,
  Apply = 0x02000000, Reset = 0x04000000, RestoreDefaults = 0x08000000, FirstButton = Ok,
  LastButton = RestoreDefaults
}
 These enums describe flags for standard buttons. More...
 
- Public Types inherited from QWidget
enum  RenderFlag { DrawWindowBackground = 0x1, DrawChildren = 0x2, IgnoreMask = 0x4 }
 This enum describes how to render the widget when calling QWidget::render(). More...
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY
}
 

Signals

void 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 . More...
 
void clicked (QAbstractButton *button)
 This signal is emitted when a button inside the button box is clicked. More...
 
void helpRequested ()
 This signal is emitted when a button inside the button box is clicked, as long as it was defined with the HelpRole . More...
 
void 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 . More...
 
- Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 This signal is emitted when the widget's contextMenuPolicy is Qt::CustomContextMenu, and the user has requested a context menu on the widget. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

void addButton (QAbstractButton *button, ButtonRole role)
 Adds the given button to the button box with the specified role. More...
 
QPushButtonaddButton (const QString &text, 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. More...
 
QPushButtonaddButton (StandardButton button)
 Adds a standard button to the button box if it is valid to do so, and returns a push button. More...
 
QPushButtonbutton (StandardButton which) const
 Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn't exist in this button box. More...
 
ButtonRole buttonRole (QAbstractButton *button) const
 Returns the button role for the specified button. More...
 
QList< QAbstractButton * > buttons () const
 Returns a list of all the buttons that have been added to the button box. More...
 
bool centerButtons () const
 
void clear ()
 Clears the button box, deleting all buttons within it. More...
 
Qt::Orientation orientation () const
 
 QDialogButtonBox (QWidget *parent=0)
 Constructs an empty, horizontal button box with the given parent. More...
 
 QDialogButtonBox (Qt::Orientation orientation, QWidget *parent=0)
 Constructs an empty button box with the given orientation and parent. More...
 
 QDialogButtonBox (StandardButtons buttons, Qt::Orientation orientation=Qt::Horizontal, QWidget *parent=0)
 Constructs a button box with the given orientation and parent, containing the standard buttons specified by buttons. More...
 
void removeButton (QAbstractButton *button)
 Removes button from the button box without deleting it and sets its parent to zero. More...
 
void setCenterButtons (bool center)
 
void setOrientation (Qt::Orientation orientation)
 
void setStandardButtons (StandardButtons buttons)
 
StandardButton standardButton (QAbstractButton *button) const
 Returns the standard button enum value corresponding to the given button, or NoButton if the given button isn't a standard button. More...
 
StandardButtons standardButtons () const
 
 ~QDialogButtonBox ()
 Destroys the button box. More...
 
- Public Functions inherited from QWidget
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 Returns the (possibly empty) list of this widget's actions. More...
 
void activateWindow ()
 Sets the top-level widget containing this widget to be the active window. More...
 
void addAction (QAction *action)
 Appends the action action to this widget's list of actions. More...
 
void addActions (QList< QAction *> actions)
 Appends the actions actions to this widget's list of actions. More...
 
void adjustSize ()
 Adjusts the size of the widget to fit its contents. More...
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 Returns the background role of the widget. More...
 
QSize baseSize () const
 
QWidgetchildAt (int x, int y) const
 Returns the visible child widget at the position ({x}, {y}) in the widget's coordinate system. More...
 
QWidgetchildAt (const QPoint &p) const
 Returns the visible child widget at point p in the widget's own coordinate system. More...
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 Takes keyboard input focus from the widget. More...
 
void clearMask ()
 Removes any mask set by setMask(). More...
 
QMargins contentsMargins () const
 The contentsMargins function returns the widget's contents margins. More...
 
QRect contentsRect () const
 Returns the area inside the widget's margins. More...
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
void createWinId ()
 
QCursor cursor () const
 
int devType () const
 
WId effectiveWinId () const
 Returns the effective window system identifier of the widget, i. More...
 
void ensurePolished () const
 Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette). More...
 
Qt::FocusPolicy focusPolicy () const
 
QWidgetfocusProxy () const
 Returns the focus proxy, or 0 if there is no focus proxy. More...
 
QWidgetfocusWidget () const
 Returns the last child of this widget that setFocus had been called on. More...
 
const QFontfont () const
 
QFontInfo fontInfo () const
 Returns the font info for the widget's current font. More...
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the widget's current font. More...
 
QPalette::ColorRole foregroundRole () const
 Returns the foreground role. More...
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the widget's contents margins for left, top, right, and bottom. More...
 
HDC getDC () const
 Returns the window system handle of the widget, for low-level access. More...
 
void grabGesture (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags())
 Subscribes the widget to a given gesture with specific flags. More...
 
void grabKeyboard ()
 Grabs the keyboard input. More...
 
void grabMouse ()
 Grabs the mouse input. More...
 
void grabMouse (const QCursor &)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. More...
 
QGraphicsEffectgraphicsEffect () const
 The graphicsEffect function returns a pointer to the widget's graphics effect. More...
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 Returns the proxy widget for the corresponding embedded widget in a graphics view; otherwise returns 0. More...
 
bool hasFocus () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int) const
 Returns the preferred height for this widget, given the width w. More...
 
QInputContextinputContext ()
 This function returns the QInputContext for this widget. More...
 
Qt::InputMethodHints inputMethodHints () const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery) const
 This method is only relevant for input widgets. More...
 
void insertAction (QAction *before, QAction *action)
 Inserts the action action to this widget's list of actions, before the action before. More...
 
void insertActions (QAction *before, QList< QAction *> actions)
 Inserts the actions actions to this widget's list of actions, before the action before. More...
 
WId internalWinId () const
 Returns the window system identifier of the widget, or 0 if the widget is not created yet. More...
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child, and both widgets are within the same window; otherwise returns false. More...
 
bool isEnabled () const
 
bool isEnabledTo (QWidget *) const
 Returns true if this widget would become enabled if ancestor is enabled; otherwise returns false. More...
 
bool isEnabledToTLW () const
 This function is deprecated. More...
 
bool isFullScreen () const
 
bool isHidden () const
 Returns true if the widget is hidden, otherwise returns false. More...
 
bool isLeftToRight () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isRightToLeft () const
 
bool isTopLevel () const
 Use isWindow() instead. More...
 
bool isVisible () const
 
bool isVisibleTo (QWidget *) const
 Returns true if this widget would become visible if ancestor is shown; otherwise returns false. More...
 
bool isWindow () const
 Returns true if the widget is an independent window, otherwise returns false. More...
 
bool isWindowModified () const
 
QLayoutlayout () const
 Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed. More...
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
Qt::HANDLE macCGHandle () const
 Returns the CoreGraphics handle of the widget. More...
 
Qt::HANDLE macQDHandle () const
 Returns the QuickDraw handle of the widget. More...
 
QPoint mapFrom (QWidget *, const QPoint &) const
 Translates the widget coordinate pos from the coordinate system of parent to this widget's coordinate system. More...
 
QPoint mapFromGlobal (const QPoint &) const
 Translates the global screen coordinate pos to widget coordinates. More...
 
QPoint mapFromParent (const QPoint &) const
 Translates the parent widget coordinate pos to widget coordinates. More...
 
QPoint mapTo (QWidget *, const QPoint &) const
 Translates the widget coordinate pos to the coordinate system of parent. More...
 
QPoint mapToGlobal (const QPoint &) const
 Translates the widget coordinate pos to global screen coordinates. More...
 
QPoint mapToParent (const QPoint &) const
 Translates the widget coordinate pos to a coordinate in the parent widget. More...
 
QRegion mask () const
 Returns the mask currently set on a widget. More...
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (int x, int y)
 This corresponds to move(QPoint(x, y)). More...
 
void move (const QPoint &)
 
QWidgetnativeParentWidget () const
 Returns the native parent for this widget, i. More...
 
QWidgetnextInFocusChain () const
 Returns the next widget in this widget's focus chain. More...
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags type)
 Sets the window flags for the widget to flags, without telling the window system. More...
 
void overrideWindowState (Qt::WindowStates state)
 
QPaintEnginepaintEngine () const
 Returns the widget's paint engine. More...
 
const QPalettepalette () const
 
QWidgetparentWidget () const
 Returns the parent of this widget, or 0 if it does not have any parent widget. More...
 
QPoint pos () const
 
QWidgetpreviousInFocusChain () const
 The previousInFocusChain function returns the previous widget in this widget's focus chain. More...
 
 QWidget (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a widget which is a child of parent, with widget flags set to f. More...
 
QRect rect () const
 
void releaseDC (HDC) const
 Releases the HDC hdc acquired by a previous call to getDC(). More...
 
void releaseKeyboard ()
 Releases the keyboard grab. More...
 
void releaseMouse ()
 Releases the mouse grab. More...
 
void releaseShortcut (int id)
 Removes the shortcut with the given id from Qt's shortcut system. More...
 
void removeAction (QAction *action)
 Removes the action action from this widget's list of actions. More...
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the sourceRegion of this widget into the target using renderFlags to determine how to render. More...
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint(), const QRegion &sourceRegion=QRegion(), RenderFlags renderFlags=RenderFlags(DrawWindowBackground|DrawChildren))
 Renders the widget into the painter's QPainter::device(). More...
 
void repaint (int x, int y, int w, int h)
 This version repaints a rectangle (x, y, w, h) inside the widget. More...
 
void repaint (const QRect &)
 This version repaints a rectangle rect inside the widget. More...
 
void repaint (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void resize (int w, int h)
 This corresponds to resize(QSize(w, h)). More...
 
void resize (const QSize &)
 
bool restoreGeometry (const QByteArray &geometry)
 Restores the geometry and state top-level widgets stored in the byte array geometry. More...
 
QByteArray saveGeometry () const
 Saves the current geometry and state for top-level widgets. More...
 
void scroll (int dx, int dy)
 Scrolls the widget including its children dx pixels to the right and dy downward. More...
 
void scroll (int dx, int dy, const QRect &)
 This version only scrolls r and does not move the children of the widget. More...
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute, bool on=true)
 Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. More...
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole)
 Sets the background role of the widget to role. More...
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 This corresponds to setBaseSize(QSize(basew, baseh)). More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom. More...
 
void setContentsMargins (const QMargins &margins)
 The setContentsMargins function sets the margins around the widget's contents. More...
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setFixedHeight (int h)
 Sets both the minimum and maximum heights of the widget to h without changing the widths. More...
 
void setFixedSize (const QSize &)
 Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing or shrinking. More...
 
void setFixedSize (int w, int h)
 Sets the width of the widget to w and the height to h. More...
 
void setFixedWidth (int w)
 Sets both the minimum and maximum width of the widget to w without changing the heights. More...
 
void setFocus (Qt::FocusReason reason)
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *)
 Sets the widget's focus proxy to widget w. More...
 
void setFont (const QFont &)
 Use the single-argument overload instead. More...
 
void setForegroundRole (QPalette::ColorRole)
 Sets the foreground role of the widget to role. More...
 
void setGeometry (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This corresponds to setGeometry(QRect(x, y, w, h)). More...
 
void setGeometry (const QRect &)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 The setGraphicsEffect function is for setting the widget's graphics effect. More...
 
void setInputContext (QInputContext *)
 This function sets the input context context on this widget. More...
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *)
 Sets the layout manager for this widget to layout. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &)
 Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. More...
 
void setMask (const QRegion &)
 Causes only the parts of the widget which overlap region to be visible. More...
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 This function corresponds to setMaximumSize(QSize(maxw, maxh)). More...
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 This function corresponds to setMinimumSize(QSize(minw, minh)). More...
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 Use the single-argument overload instead. More...
 
void setParent (QWidget *parent)
 Sets the parent of the widget to parent, and resets the window flags. More...
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 This function also takes widget flags, f as an argument. More...
 
void setShortcutAutoRepeat (int id, bool enable=true)
 If enable is true, auto repeat of the shortcut with the given id is enabled; otherwise it is disabled. More...
 
void setShortcutEnabled (int id, bool enable=true)
 If enable is true, the shortcut with the given id is enabled; otherwise the shortcut is disabled. More...
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 Sets the x (width) size increment to w and the y (height) size increment to h. More...
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 Sets the size policy of the widget to horizontal and vertical, with standard stretch and no height-for-width. More...
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *)
 Sets the widget's GUI style to style. More...
 
void setToolTip (const QString &)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 Sets up the user interface for the specified widget. More...
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &)
 Sets the window's role to role. More...
 
void setWindowState (Qt::WindowStates state)
 Sets the window state to windowState. More...
 
void setWindowSurface (QWindowSurface *surface)
 Sets the window surface to be the surface specified. More...
 
QSize size () const
 
virtual QSize sizeHint () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *)
 Places the widget under w in the parent widget's stack. More...
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute) const
 Returns true if attribute attribute is set on this widget; otherwise returns false. More...
 
QString toolTip () const
 
QWidgettopLevelWidget () const
 
bool underMouse () const
 Returns true if the widget is under the mouse cursor; otherwise returns false. More...
 
void ungrabGesture (Qt::GestureType type)
 Unsubscribes the widget from a given gesture type. More...
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (int x, int y, int w, int h)
 This version updates a rectangle (x, y, w, h) inside the widget. More...
 
void update (const QRect &)
 This version updates a rectangle rect inside the widget. More...
 
void update (const QRegion &)
 This version repaints a region rgn inside the widget. More...
 
void updateGeometry ()
 Notifies the layout system that this widget has changed and may need to change geometry. More...
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 Returns the unobscured region where paint events can occur. More...
 
QString whatsThis () const
 
int width () const
 
QWidgetwindow () const
 Returns the window for this widget, i.e. More...
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 Window flags are a combination of a type (e. More...
 
QIcon windowIcon () const
 
QString windowIconText () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 Returns the window's role, or an empty string. More...
 
Qt::WindowStates windowState () const
 Returns the current window state. More...
 
QWindowSurfacewindowSurface () const
 Returns the QWindowSurface this widget will be drawn into. More...
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 Returns the window type of this widget. More...
 
WId winId () const
 Returns the window system identifier of the widget. More...
 
int x () const
 
const QX11Infox11Info () const
 Returns information about the configuration of the X display used to display the widget. More...
 
Qt::HANDLE x11PictureHandle () const
 Returns the X11 Picture handle of the widget for XRender support. More...
 
int y () const
 
 ~QWidget ()
 Destroys the widget. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QPaintDevice
int colorCount () const
 
int depth () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
QT_DEPRECATED int numColors () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 
virtual ~QPaintDevice ()
 

Protected Functions

void changeEvent (QEvent *event)
 Reimplemented Function More...
 
bool event (QEvent *event)
 Reimplemented Function More...
 
- Protected Functions inherited from QWidget
virtual void actionEvent (QActionEvent *)
 This event handler is called with the given event whenever the widget's actions are changed. More...
 
virtual void closeEvent (QCloseEvent *)
 This event handler is called with the given event when Qt receives a window close request for a top-level widget from the window system. More...
 
virtual void contextMenuEvent (QContextMenuEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive widget context menu events. More...
 
void create (WId=0, bool initializeWindow=true, bool destroyOldWindow=true)
 Creates a new widget window if window is 0, otherwise sets the widget's window to window. More...
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 Frees up window system resources. More...
 
virtual void dragEnterEvent (QDragEnterEvent *)
 This event handler is called when a drag is in progress and the mouse enters this widget. More...
 
virtual void dragLeaveEvent (QDragLeaveEvent *)
 This event handler is called when a drag is in progress and the mouse leaves this widget. More...
 
virtual void dragMoveEvent (QDragMoveEvent *)
 This event handler is called if a drag is in progress, and when any of the following conditions occur: the cursor enters this widget, the cursor moves within this widget, or a modifier key is pressed on the keyboard while this widget has the focus. More...
 
virtual void dropEvent (QDropEvent *)
 This event handler is called when the drag is dropped on this widget. More...
 
virtual void enabledChange (bool)
 
virtual void enterEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget enter events which are passed in the event parameter. More...
 
virtual void focusInEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget. More...
 
bool focusNextChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual bool focusNextPrevChild (bool next)
 Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void focusOutEvent (QFocusEvent *)
 This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget. More...
 
bool focusPreviousChild ()
 Finds a new widget to give the keyboard focus to, as appropriate for Shift+Tab, and returns true if it can find a new widget, or false if it can't. More...
 
virtual void fontChange (const QFont &)
 
virtual void hideEvent (QHideEvent *)
 This event handler can be reimplemented in a subclass to receive widget hide events. More...
 
virtual void inputMethodEvent (QInputMethodEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive Input Method composition events. More...
 
virtual void keyPressEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key press events for the widget. More...
 
virtual void keyReleaseEvent (QKeyEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive key release events for the widget. More...
 
virtual void languageChange ()
 
virtual void leaveEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive widget leave events which are passed in the event parameter. More...
 
virtual bool macEvent (EventHandlerCallRef, EventRef)
 This special event handler can be reimplemented in a subclass to receive native Macintosh events. More...
 
int metric (PaintDeviceMetric) const
 Internal implementation of the virtual QPaintDevice::metric() function. More...
 
virtual void mouseDoubleClickEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse double click events for the widget. More...
 
virtual void mouseMoveEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget. More...
 
virtual void mousePressEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse press events for the widget. More...
 
virtual void mouseReleaseEvent (QMouseEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive mouse release events for the widget. More...
 
virtual void moveEvent (QMoveEvent *)
 This event handler can be reimplemented in a subclass to receive widget move events which are passed in the event parameter. More...
 
virtual void paintEvent (QPaintEvent *)
 This event handler can be reimplemented in a subclass to receive paint events passed in event. More...
 
virtual void paletteChange (const QPalette &)
 
 QWidget (QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
 
virtual bool qwsEvent (QWSEvent *)
 This special event handler can be reimplemented in a subclass to receive native Qt for Embedded Linux events which are passed in the event parameter. More...
 
void resetInputContext ()
 This function can be called on the widget that currently has focus to reset the input method operating on it. More...
 
virtual void resizeEvent (QResizeEvent *)
 This event handler can be reimplemented in a subclass to receive widget resize events which are passed in the event parameter. More...
 
virtual void showEvent (QShowEvent *)
 This event handler can be reimplemented in a subclass to receive widget show events which are passed in the event parameter. More...
 
virtual void styleChange (QStyle &)
 
virtual void tabletEvent (QTabletEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive tablet events for the widget. More...
 
virtual void wheelEvent (QWheelEvent *)
 This event handler, for event event, can be reimplemented in a subclass to receive wheel events for the widget. More...
 
virtual void windowActivationChange (bool)
 
virtual bool winEvent (MSG *message, long *result)
 This special event handler can be reimplemented in a subclass to receive native Windows events which are passed in the message parameter. More...
 
virtual bool x11Event (XEvent *)
 This special event handler can be reimplemented in a subclass to receive native X11 events passed in the event parameter. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QPaintDevice
 QPaintDevice ()
 

Properties

bool centerButtons
 whether the buttons in the button box are centered More...
 
Qt::Orientation orientation
 the orientation of the button box More...
 
StandardButtons standardButtons
 collection of standard buttons in the button box More...
 

Additional Inherited Members

- Public Slots inherited from QWidget
bool close ()
 Closes this widget. More...
 
void hide ()
 Hides the widget. More...
 
void lower ()
 Lowers the widget to the bottom of the parent widget's stack. More...
 
void raise ()
 Raises this widget to the top of the parent widget's stack. More...
 
void repaint ()
 Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. More...
 
void setDisabled (bool)
 Disables widget input events if disable is true; otherwise enables input events. More...
 
void setEnabled (bool)
 
void setFocus ()
 Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its parents is the active window. More...
 
void setHidden (bool hidden)
 Convenience function, equivalent to setVisible(!hidden). More...
 
QT_MOC_COMPAT void setShown (bool shown)
 Use setVisible(shown) instead. More...
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool)
 
void setWindowTitle (const QString &)
 
void show ()
 Shows the widget and its child widgets. More...
 
void showFullScreen ()
 Shows the widget in full-screen mode. More...
 
void showMaximized ()
 Shows the widget maximized. More...
 
void showMinimized ()
 Shows the widget minimized, as an icon. More...
 
void showNormal ()
 Restores the widget after it has been maximized or minimized. More...
 
void update ()
 Updates the widget unless updates are disabled or the widget is hidden. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QWidget
static QWidgetfind (WId)
 Returns a pointer to the widget with window identifer/handle id. More...
 
static QWidgetkeyboardGrabber ()
 Returns the widget that is currently grabbing the keyboard input. More...
 
static QWidgetmouseGrabber ()
 Returns the widget that is currently grabbing the mouse input. More...
 
static void setTabOrder (QWidget *, QWidget *)
 Puts the second widget after the first widget in the focus order. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Functions inherited from QPaintDevice
static QWSDisplayqwsDisplay ()
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 Updates the widget's micro focus. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Protected Variables inherited from QPaintDevice
ushort painters
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the current widget style.

Since
4.2

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:

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.

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.

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:

buttonbox-gnomelayout-horizontal.png
GnomeLayout Horizontal
Button box laid out in horizontal GnomeLayout
buttonbox-kdelayout-horizontal.png
KdeLayout Horizontal
Button box laid out in horizontal KdeLayout
buttonbox-maclayout-horizontal.png
MacLayout Horizontal
Button box laid out in horizontal MacLayout
buttonbox-winlayout-horizontal.png
WinLayout Horizontal
Button box laid out in horizontal WinLayout

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

GnomeLayout KdeLayout MacLayout WinLayout
buttonbox-gnomelayout-vertical.png
GnomeLayout Vertical
buttonbox-kdelayout-vertical.png
KdeLayout Vertical
buttonbox-maclayout-vertical.png
MacLayout Vertical
buttonbox-winlayout-vertical.png
WinLayout Vertical

Additionally, button boxes that contain only buttons with ActionRole or HelpRole can be considered modeless and have an alternate look on Mac OS X:

modeless horizontal MacLayout
buttonbox-mac-modeless-horizontal.png
Screenshot of modeless horizontal 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, QDialog

Definition at line 57 of file qdialogbuttonbox.h.

Enumerations

◆ ButtonLayout

This enum describes the layout policy to be used when arranging the buttons contained in the button box.

  • WinLayout Use a policy appropriate for applications on Windows.
  • MacLayout Use a policy appropriate for applications on Mac OS X.
  • KdeLayout Use a policy appropriate for applications on KDE.
  • GnomeLayout Use a policy appropriate for applications on GNOME.

The button layout is specified by the current style. However, on the X11 platform, it may be influenced by the desktop environment.

Enumerator
WinLayout 
MacLayout 
KdeLayout 
GnomeLayout 

Definition at line 112 of file qdialogbuttonbox.h.

◆ ButtonRole

This enum describes the roles that can be used to describe buttons in the button box.

Enumerator
InvalidRole 
AcceptRole 
RejectRole 
DestructiveRole 
ActionRole 
HelpRole 
YesRole 
NoRole 
ResetRole 
ApplyRole 
NRoles 

Definition at line 66 of file qdialogbuttonbox.h.

◆ StandardButton

These enums describe flags for standard buttons.

Each button has a defined ButtonRole .

  • Ok An "OK" button defined with the AcceptRole .
  • Open A "Open" button defined with the AcceptRole .
  • Save A "Save" button defined with the AcceptRole .
  • Cancel A "Cancel" button defined with the RejectRole .
  • Close A "Close" button defined with the RejectRole .
  • Discard A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole .
  • Apply An "Apply" button defined with the ApplyRole .
  • Reset A "Reset" button defined with the ResetRole .
  • RestoreDefaults A "Restore Defaults" button defined with the ResetRole .
  • Help A "Help" button defined with the HelpRole .
  • SaveAll A "Save All" button defined with the AcceptRole .
  • Yes A "Yes" button defined with the YesRole .
  • YesToAll A "Yes to All" button defined with the YesRole .
  • No A "No" button defined with the NoRole .
  • NoToAll A "No to All" button defined with the NoRole .
  • Abort An "Abort" button defined with the RejectRole .
  • Retry A "Retry" button defined with the AcceptRole .
  • Ignore An "Ignore" button defined with the AcceptRole .
  • NoButton An invalid button.
  • FirstButton
  • LastButton
See also
ButtonRole, standardButtons
Enumerator
NoButton 
Ok 
Save 
SaveAll 
Open 
Yes 
YesToAll 
No 
NoToAll 
Abort 
Retry 
Ignore 
Close 
Cancel 
Discard 
Help 
Apply 
Reset 
RestoreDefaults 
FirstButton 
LastButton 

Definition at line 82 of file qdialogbuttonbox.h.

82  {
83  // keep this in sync with QMessageBox::StandardButton
84  NoButton = 0x00000000,
85  Ok = 0x00000400,
86  Save = 0x00000800,
87  SaveAll = 0x00001000,
88  Open = 0x00002000,
89  Yes = 0x00004000,
90  YesToAll = 0x00008000,
91  No = 0x00010000,
92  NoToAll = 0x00020000,
93  Abort = 0x00040000,
94  Retry = 0x00080000,
95  Ignore = 0x00100000,
96  Close = 0x00200000,
97  Cancel = 0x00400000,
98  Discard = 0x00800000,
99  Help = 0x01000000,
100  Apply = 0x02000000,
101  Reset = 0x04000000,
102  RestoreDefaults = 0x08000000,
103 
104 #ifndef Q_MOC_RUN
105  FirstButton = Ok,
107 #endif
108  };

Constructors and Destructors

◆ QDialogButtonBox() [1/3]

QDialogButtonBox::QDialogButtonBox ( QWidget parent = 0)

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

See also
orientation, addButton()

Definition at line 749 of file qdialogbuttonbox.cpp.

751 {
752  d_func()->initLayout();
753 }
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189

◆ QDialogButtonBox() [2/3]

QDialogButtonBox::QDialogButtonBox ( Qt::Orientation  orientation,
QWidget parent = 0 
)

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

See also
orientation, addButton()

Definition at line 760 of file qdialogbuttonbox.cpp.

761  : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
762 {
763  d_func()->initLayout();
764 }
Qt::Orientation orientation() const
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189

◆ QDialogButtonBox() [3/3]

QDialogButtonBox::QDialogButtonBox ( StandardButtons  buttons,
Qt::Orientation  orientation = Qt::Horizontal,
QWidget parent = 0 
)

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

See also
orientation, addButton()

Definition at line 772 of file qdialogbuttonbox.cpp.

774  : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
775 {
776  d_func()->initLayout();
777  d_func()->createStandardButtons(buttons);
778 }
Qt::Orientation orientation() const
QWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a widget which is a child of parent, with widget flags set to f.
Definition: qwidget.cpp:1189
QList< QAbstractButton * > buttons() const
Returns a list of all the buttons that have been added to the button box.

◆ ~QDialogButtonBox()

QDialogButtonBox::~QDialogButtonBox ( )

Destroys the button box.

Definition at line 783 of file qdialogbuttonbox.cpp.

784 {
785 }

Functions

◆ accepted

void QDialogButtonBox::accepted ( )
signal

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

◆ addButton() [1/3]

void QDialogButtonBox::addButton ( QAbstractButton button,
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.

Note
The button box takes ownership of the button.
See also
removeButton(), clear()

Definition at line 1056 of file qdialogbuttonbox.cpp.

1057 {
1059  if (role <= InvalidRole || role >= NRoles) {
1060  qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
1061  return;
1062  }
1063  removeButton(button);
1064  button->setParent(this);
1065  d->addButton(button, role);
1066 }
double d
Definition: qnumeric_p.h:62
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
void removeButton(QAbstractButton *button)
Removes button from the button box without deleting it and sets its parent to zero.
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ addButton() [2/3]

QPushButton * QDialogButtonBox::addButton ( const QString text,
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(), clear()

Definition at line 1075 of file qdialogbuttonbox.cpp.

1076 {
1078  if (role <= InvalidRole || role >= NRoles) {
1079  qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
1080  return 0;
1081  }
1082  QPushButton *button = new QPushButton(text, this);
1083  d->addButton(button, role);
1084  return button;
1085 }
double d
Definition: qnumeric_p.h:62
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
#define Q_D(Class)
Definition: qglobal.h:2482
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
Q_CORE_EXPORT void qWarning(const char *,...)
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ addButton() [3/3]

QPushButton * QDialogButtonBox::addButton ( 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(), clear()

Definition at line 1094 of file qdialogbuttonbox.cpp.

1095 {
1097  return d->createButton(button);
1098 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ button()

QPushButton * QDialogButtonBox::button ( StandardButton  which) const

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(), buttons()

Definition at line 1144 of file qdialogbuttonbox.cpp.

Referenced by QInputDialogPrivate::_q_currentRowChanged(), addButton(), buttonRole(), clear(), QInputDialogPrivate::ensureEnabledConnection(), QPrintPropertiesDialog::QPrintPropertiesDialog(), removeButton(), and QInputDialogPrivate::setInputWidget().

1145 {
1146  Q_D(const QDialogButtonBox);
1147  return d->standardButtonHash.key(which);
1148 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ buttonRole()

QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole ( QAbstractButton button) const

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(), addButton()

Definition at line 993 of file qdialogbuttonbox.cpp.

Referenced by showNewMessageBox().

994 {
995  Q_D(const QDialogButtonBox);
996  for (int i = 0; i < NRoles; ++i) {
997  const QList<QAbstractButton *> &list = d->buttonLists[i];
998  for (int j = 0; j < list.count(); ++j) {
999  if (list.at(j) == button)
1000  return ButtonRole(i);
1001  }
1002  }
1003  return InvalidRole;
1004 }
double d
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
ButtonRole
This enum describes the roles that can be used to describe buttons in the button box.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ buttons()

QList< QAbstractButton * > QDialogButtonBox::buttons ( ) const

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

See also
buttonRole(), addButton(), removeButton()

Definition at line 975 of file qdialogbuttonbox.cpp.

976 {
977  Q_D(const QDialogButtonBox);
978  QList<QAbstractButton *> finalList;
979  for (int i = 0; i < NRoles; ++i) {
980  const QList<QAbstractButton *> &list = d->buttonLists[i];
981  for (int j = 0; j < list.count(); ++j)
982  finalList.append(list.at(j));
983  }
984  return finalList;
985 }
double d
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ centerButtons()

bool QDialogButtonBox::centerButtons ( ) const

Referenced by setCenterButtons().

◆ changeEvent()

void QDialogButtonBox::changeEvent ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1227 of file qdialogbuttonbox.cpp.

1228 {
1229  typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash;
1230 
1232  switch (event->type()) {
1233  case QEvent::StyleChange: // Propagate style
1234  if (!d->standardButtonHash.empty()) {
1235  QStyle *newStyle = style();
1236  const StandardButtonHash::iterator end = d->standardButtonHash.end();
1237  for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it)
1238  it.key()->setStyle(newStyle);
1239  }
1240  // fallthrough intended
1241 #ifdef Q_WS_MAC
1242  case QEvent::MacSizeChange:
1243 #endif
1244  d->resetLayout();
1245  QWidget::changeEvent(event);
1246  break;
1247  default:
1248  QWidget::changeEvent(event);
1249  break;
1250  }
1251 }
double d
Definition: qnumeric_p.h:62
#define it(className, varName)
#define Q_D(Class)
Definition: qglobal.h:2482
QStyle * style() const
Definition: qwidget.cpp:2742
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
static const KeyPair *const end
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ clear()

void QDialogButtonBox::clear ( )

Clears the button box, deleting all buttons within it.

See also
removeButton(), addButton()

Definition at line 949 of file qdialogbuttonbox.cpp.

950 {
952 #ifdef QT_SOFTKEYS_ENABLED
953  // Delete softkey actions as they have the buttons as parents
954  qDeleteAll(d->softKeyActions.values());
955  d->softKeyActions.clear();
956 #endif
957  // Remove the created standard buttons, they should be in the other lists, which will
958  // do the deletion
959  d->standardButtonHash.clear();
960  for (int i = 0; i < NRoles; ++i) {
961  QList<QAbstractButton *> &list = d->buttonLists[i];
962  while (list.count()) {
963  QAbstractButton *button = list.takeAt(0);
964  QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
965  delete button;
966  }
967  }
968 }
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
double d
Definition: qnumeric_p.h:62
#define SLOT(a)
Definition: qobjectdefs.h:226
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ clicked

void QDialogButtonBox::clicked ( QAbstractButton button)
signal

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(), helpRequested()

Referenced by removeButton().

◆ event()

bool QDialogButtonBox::event ( QEvent event)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 1256 of file qdialogbuttonbox.cpp.

1257 {
1259  if (event->type() == QEvent::Show) {
1260  QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];
1261  QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
1262  bool hasDefault = false;
1263  QWidget *dialog = 0;
1264  QWidget *p = this;
1265  while (p && !p->isWindow()) {
1266  p = p->parentWidget();
1267  if ((dialog = qobject_cast<QDialog *>(p)))
1268  break;
1269  }
1270 
1271  foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren<QPushButton *>()) {
1272  if (pb->isDefault() && pb != firstAcceptButton) {
1273  hasDefault = true;
1274  break;
1275  }
1276  }
1277  if (!hasDefault && firstAcceptButton)
1278  firstAcceptButton->setDefault(true);
1279 #ifdef QT_SOFTKEYS_ENABLED
1280  if (dialog)
1281  setFixedSize(0,0);
1282 #endif
1283  }else if (event->type() == QEvent::LanguageChange) {
1284  d->retranslateStrings();
1285  }
1286 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
1287  else if (event->type() == QEvent::ParentChange) {
1288  QWidget *dialog = 0;
1289  QWidget *p = this;
1290  while (p && !p->isWindow()) {
1291  p = p->parentWidget();
1292  if ((dialog = qobject_cast<QDialog *>(p)))
1293  break;
1294  }
1295 
1296  // If the parent changes, then move the softkeys
1297  for (QHash<QAbstractButton *, QAction *>::const_iterator it = d->softKeyActions.constBegin();
1298  it != d->softKeyActions.constEnd(); ++it) {
1299  QAction *current = it.value();
1300  QList<QWidget *> widgets = current->associatedWidgets();
1301  foreach (QWidget *w, widgets)
1302  w->removeAction(current);
1303  if (dialog)
1304  dialog->addAction(current);
1305  else
1306  addAction(current);
1307  }
1308  }
1309 #endif
1310 
1311  return QWidget::event(event);
1312 }
double d
Definition: qnumeric_p.h:62
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setDefault(bool)
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
T * qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_D(Class)
Definition: qglobal.h:2482
void addAction(QAction *action)
Appends the action action to this widget&#39;s list of actions.
Definition: qwidget.cpp:3317
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QWidget * > associatedWidgets() const
Returns a list of widgets this action has been added to.
Definition: qaction.cpp:416
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition: qwidget.cpp:4284
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void removeAction(QAction *action)
Removes the action action from this widget&#39;s list of actions.
Definition: qwidget.cpp:3386
bool isDefault() const
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ helpRequested

void QDialogButtonBox::helpRequested ( )
signal

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

◆ orientation()

Qt::Orientation QDialogButtonBox::orientation ( ) const

◆ rejected

void QDialogButtonBox::rejected ( )
signal

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

◆ removeButton()

void QDialogButtonBox::removeButton ( QAbstractButton button)

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

See also
clear(), buttons(), addButton()

Definition at line 1011 of file qdialogbuttonbox.cpp.

Referenced by addButton().

1012 {
1014 
1015  if (!button)
1016  return;
1017 
1018  // Remove it from the standard button hash first and then from the roles
1019  if (QPushButton *pushButton = qobject_cast<QPushButton *>(button))
1020  d->standardButtonHash.remove(pushButton);
1021  for (int i = 0; i < NRoles; ++i) {
1022  QList<QAbstractButton *> &list = d->buttonLists[i];
1023  for (int j = 0; j < list.count(); ++j) {
1024  if (list.at(j) == button) {
1025  list.takeAt(j);
1026  if (!d->internalRemove) {
1027  disconnect(button, SIGNAL(clicked()), this, SLOT(_q_handleButtonClicked()));
1028  disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
1029  }
1030  break;
1031  }
1032  }
1033  }
1034 #if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
1035  QAction *action = d->softKeyActions.value(button, 0);
1036  if (action) {
1037  d->softKeyActions.remove(button);
1038  delete action;
1039  }
1040 #endif
1041  if (!d->internalRemove)
1042  button->setParent(0);
1043 }
double d
Definition: qnumeric_p.h:62
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
#define SLOT(a)
Definition: qobjectdefs.h:226
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or 0 if the standard button doesn...
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void clicked(QAbstractButton *button)
This signal is emitted when a button inside the button box is clicked.
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
T takeAt(int i)
Removes the item at index position i and returns it.
Definition: qlist.h:484
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ setCenterButtons()

void QDialogButtonBox::setCenterButtons ( bool  center)

Definition at line 1209 of file qdialogbuttonbox.cpp.

1210 {
1212  if (d->center != center) {
1213  d->center = center;
1214  d->resetLayout();
1215  }
1216 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ setOrientation()

void QDialogButtonBox::setOrientation ( Qt::Orientation  orientation)

Definition at line 934 of file qdialogbuttonbox.cpp.

935 {
937  if (orientation == d->orientation)
938  return;
939 
940  d->orientation = orientation;
941  d->resetLayout();
942 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::Orientation orientation() const
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ setStandardButtons()

void QDialogButtonBox::setStandardButtons ( StandardButtons  buttons)

Definition at line 1111 of file qdialogbuttonbox.cpp.

1112 {
1114 #ifdef QT_SOFTKEYS_ENABLED
1115  // Delete softkey actions since they have the buttons as parents
1116  qDeleteAll(d->softKeyActions.values());
1117  d->softKeyActions.clear();
1118 #endif
1119  // Clear out all the old standard buttons, then recreate them.
1120  qDeleteAll(d->standardButtonHash.keys());
1121  d->standardButtonHash.clear();
1122 
1123  d->createStandardButtons(buttons);
1124 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QList< QAbstractButton * > buttons() const
Returns a list of all the buttons that have been added to the button box.
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ standardButton()

QDialogButtonBox::StandardButton QDialogButtonBox::standardButton ( QAbstractButton button) const

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(), standardButtons()

Definition at line 1156 of file qdialogbuttonbox.cpp.

1157 {
1158  Q_D(const QDialogButtonBox);
1159  return d->standardButtonHash.value(static_cast<QPushButton *>(button));
1160 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...

◆ standardButtons()

StandardButtons QDialogButtonBox::standardButtons ( ) const

Referenced by setStandardButtons().

Properties

◆ centerButtons

bool QDialogButtonBox::centerButtons
private

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

Definition at line 63 of file qdialogbuttonbox.h.

◆ orientation

Qt::Orientation QDialogButtonBox::orientation
private

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.

Definition at line 61 of file qdialogbuttonbox.h.

◆ standardButtons

QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons
private

collection of standard buttons in the button box

This property controls which standard buttons are used by the button box.

See also
addButton()

Definition at line 62 of file qdialogbuttonbox.h.


The documentation for this class was generated from the following files: