Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Protected Functions | Properties | Friends | List of all members
QDialog Class Reference

The QDialog class is the base class of dialog windows. More...

#include <qdialog.h>

Inheritance diagram for QDialog:
QWidget QObject QPaintDevice QAbstractPageSetupDialog QAbstractPrintDialog QAxSelect QColorDialog QErrorMessage QFileDialog QFontDialog QInputDialog QMessageBox QPrintPreviewDialog QPrintPropertiesDialog QProgressDialog QWizard

Public Types

enum  DialogCode { Rejected, Accepted }
 The value returned by a modal dialog. 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
}
 

Public Slots

virtual void accept ()
 Hides the modal dialog and sets the result code to Accepted. More...
 
virtual void done (int)
 Closes the dialog and sets its result code to r. More...
 
int exec ()
 Shows the dialog as a modal dialog, blocking until the user closes it. More...
 
void open ()
 Shows the dialog as a window modal dialog, returning immediately. More...
 
virtual void reject ()
 Hides the modal dialog and sets the result code to Rejected. More...
 
void showExtension (bool)
 If showIt is true, the dialog's extension is shown; otherwise the extension is hidden. More...
 
- 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)
 
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...
 

Signals

void accepted ()
 This signal is emitted when the dialog has been accepted either by the user or by calling accept() or done() with the QDialog::Accepted argument. More...
 
void finished (int result)
 This signal is emitted when the dialog's result code has been set, either by the user or by calling done(), accept(), or reject(). More...
 
void rejected ()
 This signal is emitted when the dialog has been rejected either by the user or by calling reject() or done() with the QDialog::Rejected argument. 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

QWidgetextension () const
 Returns the dialog's extension or 0 if no extension has been defined. More...
 
bool isSizeGripEnabled () const
 
QSize minimumSizeHint () const
 Reimplemented Function More...
 
Qt::Orientation orientation () const
 Returns the dialog's extension orientation. More...
 
 QDialog (QWidget *parent=0, Qt::WindowFlags f=0)
 Constructs a dialog with parent parent. More...
 
int result () const
 In general returns the modal dialog's result code, Accepted or Rejected. More...
 
void setExtension (QWidget *extension)
 Sets the widget, extension, to be the dialog's extension, deleting any previous extension. More...
 
void setModal (bool modal)
 
void setOrientation (Qt::Orientation orientation)
 If orientation is Qt::Horizontal, the extension will be displayed to the right of the dialog's main area. More...
 
void setResult (int r)
 Sets the modal dialog's result code to i. More...
 
void setSizeGripEnabled (bool)
 
void setVisible (bool visible)
 Reimplemented Function More...
 
QSize sizeHint () const
 Reimplemented Function More...
 
 ~QDialog ()
 Destroys the QDialog, deleting all its children. 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
 
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
 
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...
 
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 adjustPosition (QWidget *)
 
void closeEvent (QCloseEvent *)
 Reimplemented Function More...
 
void contextMenuEvent (QContextMenuEvent *)
 Reimplemented Function More...
 
bool event (QEvent *e)
 Reimplemented Function More...
 
bool eventFilter (QObject *, QEvent *)
 Reimplemented Function More...
 
void keyPressEvent (QKeyEvent *)
 Reimplemented Function More...
 
 QDialog (QDialogPrivate &, QWidget *parent, Qt::WindowFlags f=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void resizeEvent (QResizeEvent *)
 Reimplemented Function More...
 
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...
 
- 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 changeEvent (QEvent *)
 This event handler can be reimplemented to handle state changes. 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...
 
bool event (QEvent *)
 This is the main event handler; it handles event event. 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 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 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 modal
 whether show() should pop up the dialog as modal or modeless More...
 
bool sizeGripEnabled
 whether the size grip is enabled More...
 

Friends

class QPushButton
 

Additional Inherited Members

- 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 QDialog class is the base class of dialog windows.

A dialog window is a top-level window mostly used for short-term tasks and brief communications with the user. QDialogs may be modal or modeless. QDialogs can provide a return value, and they can have default buttons. QDialogs can also have a QSizeGrip in their lower-right corner, using setSizeGripEnabled().

Note that QDialog (and any other widget that has type Qt::Dialog) uses the parent widget slightly differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.

Use the overload of the QWidget::setParent() function to change the ownership of a QDialog widget. This function allows you to explicitly set the window flags of the reparented widget; using the overloaded function will clear the window flags specifying the window-system properties for the widget (in particular it will reset the Qt::Dialog flag).

Modal Dialogs

A modal dialog is a dialog that blocks input to other visible windows in the same application. Dialogs that are used to request a file name from the user or that are used to set application preferences are usually modal. Dialogs can be application modal (the default) or window modal.

When an application modal dialog is opened, the user must finish interacting with the dialog and close it before they can access any other window in the application. Window modal dialogs only block access to the window associated with the dialog, allowing the user to continue to use other windows in an application.

The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will provide a useful return value. Typically, to get the dialog to close and return the appropriate value, we connect a default button, e.g. OK, to the accept() slot and a Cancel button to the reject() slot. Alternatively you can call the done() slot with Accepted or Rejected.

An alternative is to call setModal(true) or setWindowModality(), then show(). Unlike exec(), show() returns control to the caller immediately. Calling setModal(true) is especially useful for progress dialogs, where the user must have the ability to interact with the dialog, e.g. to cancel a long running operation. If you use show() and setModal(true) together to perform a long operation, you must call QApplication::processEvents() periodically during processing to enable the user to interact with the dialog. (See QProgressDialog.)

Modeless Dialogs

A modeless dialog is a dialog that operates independently of other windows in the same application. Find and replace dialogs in word-processors are often modeless to allow the user to interact with both the application's main window and with the dialog.

Modeless dialogs are displayed using show(), which returns control to the caller immediately.

If you invoke the show() function after hiding a dialog, the dialog will be displayed in its original position. This is because the window manager decides the position for windows that have not been explicitly placed by the programmer. To preserve the position of a dialog that has been moved by the user, save its position in your closeEvent() handler and then move the dialog to that position, before showing it again.

Default Button

A dialog's default button is the button that's pressed when the user presses Enter (Return). This button is used to signify that the user accepts the dialog's settings and wants to close the dialog. Use QPushButton::setDefault(), QPushButton::isDefault() and QPushButton::autoDefault() to set and control the dialog's default button.

Escape Key

If the user presses the Esc key in a dialog, QDialog::reject() will be called. This will cause the window to close: The close event cannot be ignored .

Extensibility

Extensibility is the ability to show the dialog in two ways: a partial dialog that shows the most commonly used options, and a full dialog that shows all the options. Typically an extensible dialog will initially appear as a partial dialog, but with a More toggle button. If the user presses the More button down, the dialog is expanded. The Extension Example shows how to achieve extensible dialogs using Qt.

(Modal-Dialogs)

Return Value (Modal Dialogs)

Modal dialogs are often used in situations where a return value is required, e.g. to indicate whether the user pressed OK or Cancel. A dialog can be closed by calling the accept() or the reject() slots, and exec() will return Accepted or Rejected as appropriate. The exec() call returns the result of the dialog. The result is also available from result() if the dialog has not been destroyed.

In order to modify your dialog's close behavior, you can reimplement the functions accept(), reject() or done(). The closeEvent() function should only be reimplemented to preserve the dialog's position or to override the standard close or reject behavior.

Code Examples

A modal dialog:

void EditorWindow::countWords()
{
WordCountDialog dialog(this);
dialog.setWordCount(document().wordCount());
dialog.exec();
}

A modeless dialog:

void EditorWindow::find()
{
if (!findDialog) {
findDialog = new FindDialog(this);
connect(findDialog, SIGNAL(findNext()), this, SLOT(findNext()));
}
findDialog->show();
findDialog->raise();
findDialog->activateWindow();
}
See also
QDialogButtonBox, QTabWidget, QWidget, QProgressDialog, {fowler}{GUI Design Handbook: Dialogs, Standard}, {Extension Example}, {Standard Dialogs Example}

Definition at line 56 of file qdialog.h.

Enumerations

◆ DialogCode

The value returned by a modal dialog.

  • Accepted
  • Rejected
Enumerator
Rejected 
Accepted 

Definition at line 72 of file qdialog.h.

Constructors and Destructors

◆ QDialog() [1/2]

QDialog::QDialog ( QWidget parent = 0,
Qt::WindowFlags  f = 0 
)
explicit

Constructs a dialog with parent parent.

A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent. It will also share the parent's taskbar entry.

The widget flags f are passed on to the QWidget constructor. If, for example, you don't want a What's This button in the title bar of the dialog, pass Qt::WindowTitleHint | Qt::WindowSystemMenuHint in f.

See also
QWidget::setWindowFlags()

Definition at line 268 of file qdialog.cpp.

Referenced by QMessageBox::setWindowModality().

269  : QWidget(*new QDialogPrivate, parent,
270  f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
271 {
272 #ifdef Q_WS_WINCE
273  if (!qt_wince_is_smartphone())
275 #endif
276 
277 #ifdef Q_WS_S60
278  if (S60->avkonComponentsSupportTransparency) {
279  bool noSystemBackground = testAttribute(Qt::WA_NoSystemBackground);
280  setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground
281  setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute
282  }
283 #endif
284 }
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
WindowType
Definition: qnamespace.h:270
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool qt_wince_is_smartphone()
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
void setWindowFlags(Qt::WindowFlags type)
Definition: qwidget.cpp:10399
bool qt_wince_is_mobile()
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

◆ ~QDialog()

QDialog::~QDialog ( )

Destroys the QDialog, deleting all its children.

Definition at line 327 of file qdialog.cpp.

328 {
329  QT_TRY {
330  // Need to hide() here, as our (to-be) overridden hide()
331  // will not be called in ~QWidget.
332  hide();
333  } QT_CATCH(...) {
334  // we're in the destructor - just swallow the exception
335  }
336 }
#define QT_CATCH(A)
Definition: qglobal.h:1537
void hide()
Hides the widget.
Definition: qwidget.h:501
#define QT_TRY
Definition: qglobal.h:1536

◆ QDialog() [2/2]

QDialog::QDialog ( QDialogPrivate dd,
QWidget parent,
Qt::WindowFlags  f = 0 
)
protected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Warning
This function is not part of the public interface.

Definition at line 306 of file qdialog.cpp.

307  : QWidget(dd, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0)))
308 {
309 #ifdef Q_WS_WINCE
310  if (!qt_wince_is_smartphone())
312 #endif
313 
314 #ifdef Q_WS_S60
315  if (S60->avkonComponentsSupportTransparency) {
316  bool noSystemBackground = testAttribute(Qt::WA_NoSystemBackground);
317  setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground
318  setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute
319  }
320 #endif
321 }
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
WindowType
Definition: qnamespace.h:270
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool qt_wince_is_smartphone()
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
void setWindowFlags(Qt::WindowFlags type)
Definition: qwidget.cpp:10399
bool qt_wince_is_mobile()
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939

Functions

◆ accept

void QDialog::accept ( )
virtualslot

Hides the modal dialog and sets the result code to Accepted.

See also
reject() done()

Reimplemented in QFileDialog.

Definition at line 639 of file qdialog.cpp.

Referenced by QFileDialog::accept(), QPrintPropertiesDialog::addItemToOptions(), event(), QFontDialogPrivate::init(), QAxSelect::on_ActiveXList_doubleClicked(), QAxSelect::QAxSelect(), QErrorMessage::QErrorMessage(), QPrintPropertiesDialog::QPrintPropertiesDialog(), and QPrintDialogPrivate::selectPrinter().

640 {
641  done(Accepted);
642 }
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition: qdialog.cpp:617

◆ accepted

void QDialog::accepted ( )
signal

This signal is emitted when the dialog has been accepted either by the user or by calling accept() or done() with the QDialog::Accepted argument.

Since
4.1

Note that this signal is not emitted when hiding the dialog with hide() or setVisible(false). This includes deleting the dialog while it is visible.

See also
finished(), rejected()

Referenced by QPrintPropertiesDialog::addItemToOptions(), QAbstractPageSetupDialog::done(), QPrintDialog::done(), done(), QFontDialogPrivate::init(), and QPrintDialog::open().

◆ adjustPosition()

void QDialog::adjustPosition ( QWidget w)
protected
Warning
This function is not part of the public interface.

Definition at line 850 of file qdialog.cpp.

Referenced by event(), setVisible(), and showEvent().

851 {
852 #ifdef Q_WS_X11
853  // if the WM advertises that it will place the windows properly for us, let it do it :)
854  if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT)))
855  return;
856 #endif
857 
858 #ifdef Q_OS_SYMBIAN
859  if (symbianAdjustedPosition())
860  //dialog has already been positioned
861  return;
862 #endif
863 
864  QPoint p(0, 0);
865  int extraw = 0, extrah = 0, scrn = 0;
866  if (w)
867  w = w->window();
868  QRect desk;
869  if (w) {
870  scrn = QApplication::desktop()->screenNumber(w);
871  } else if (QApplication::desktop()->isVirtualDesktop()) {
873  } else {
874  scrn = QApplication::desktop()->screenNumber(this);
875  }
877 
879  for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) {
880  QWidget * current = list.at(i);
881  if (current->isVisible()) {
882  int framew = current->geometry().x() - current->x();
883  int frameh = current->geometry().y() - current->y();
884 
885  extraw = qMax(extraw, framew);
886  extrah = qMax(extrah, frameh);
887  }
888  }
889 
890  // sanity check for decoration frames. With embedding, we
891  // might get extraordinary values
892  if (extraw == 0 || extrah == 0 || extraw >= 10 || extrah >= 40) {
893  extrah = 40;
894  extraw = 10;
895  }
896 
897 
898  if (w) {
899  // Use mapToGlobal rather than geometry() in case w might
900  // be embedded in another application
901  QPoint pp = w->mapToGlobal(QPoint(0,0));
902  p = QPoint(pp.x() + w->width()/2,
903  pp.y() + w->height()/ 2);
904  } else {
905  // p = middle of the desktop
906  p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2);
907  }
908 
909  // p = origin of this
910  p = QPoint(p.x()-width()/2 - extraw,
911  p.y()-height()/2 - extrah);
912 
913 
914  if (p.x() + extraw + width() > desk.x() + desk.width())
915  p.setX(desk.x() + desk.width() - width() - extraw);
916  if (p.x() < desk.x())
917  p.setX(desk.x());
918 
919  if (p.y() + extrah + height() > desk.y() + desk.height())
920  p.setY(desk.y() + desk.height() - height() - extrah);
921  if (p.y() < desk.y())
922  p.setY(desk.y());
923 
924  move(p);
925 }
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
bool isVisible() const
Definition: qwidget.h:1005
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define X11
Definition: qt_x11_p.h:724
int x
the x coordinate of the widget relative to its parent including any window frame
Definition: qwidget.h:161
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define ATOM(x)
Definition: qt_x11_p.h:723
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
int width() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
Definition: qpoint.h:137
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int y
the y coordinate of the widget relative to its parent and including any window frame ...
Definition: qwidget.h:162
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
int screenNumber(const QWidget *widget=0) const
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
const QRect availableGeometry(int screen=-1) const
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
Definition: qpoint.h:134
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
void move(int x, int y)
This corresponds to move(QPoint(x, y)).
Definition: qwidget.h:1011
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ closeEvent()

void QDialog::closeEvent ( QCloseEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QMessageBox, and QProgressDialog.

Definition at line 733 of file qdialog.cpp.

Referenced by QProgressDialog::closeEvent(), QMessageBox::closeEvent(), and QMessageBox::critical().

734 {
735 #ifndef QT_NO_WHATSTHIS
738 #endif
739  if (isVisible()) {
740  QPointer<QObject> that = this;
741  reject();
742  if (that && isVisible())
743  e->ignore();
744  } else {
745  e->accept();
746  }
747 }
bool isModal() const
Definition: qwidget.h:951
bool isVisible() const
Definition: qwidget.h:1005
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
Definition: qdialog.cpp:650
static bool inWhatsThisMode()
Returns true if the user interface is in "What&#39;s This?" mode; otherwise returns false.
Definition: qwhatsthis.cpp:648
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Definition: qcoreevent.h:309
static void leaveWhatsThisMode()
If the user interface is in "What&#39;s This?" mode, this function switches back to normal mode; otherwis...
Definition: qwhatsthis.cpp:662

◆ contextMenuEvent()

void QDialog::contextMenuEvent ( QContextMenuEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Definition at line 667 of file qdialog.cpp.

668 {
669 #if defined(QT_NO_WHATSTHIS) || defined(QT_NO_MENU)
670  Q_UNUSED(e);
671 #else
672  QWidget *w = childAt(e->pos());
673  if (!w) {
674  w = rect().contains(e->pos()) ? this : 0;
675  if (!w)
676  return;
677  }
678  while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis))
679  w = w->isWindow() ? 0 : w->parentWidget();
680  if (w) {
681  QWeakPointer<QMenu> p = new QMenu(this);
682  QAction *wt = p.data()->addAction(tr("What's This?"));
683  if (p.data()->exec(e->globalPos()) == wt) {
685  w->mapToGlobal(w->rect().center()));
687  }
688  delete p.data();
689  }
690 #endif
691 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
QString whatsThis
the widget&#39;s What&#39;s This help text.
Definition: qwidget.h:210
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
const QPoint & pos() const
Returns the position of the mouse pointer relative to the widget that received the event...
Definition: qevent.h:412
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
T * data() const
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
QWidget * childAt(int x, int y) const
Returns the visible child widget at the position ({x}, {y}) in the widget&#39;s coordinate system...
Definition: qwidget.h:934
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
QRect rect() const
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
QPoint center() const
Returns the center point of the rectangle.
Definition: qrect.h:300
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:168
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QWeakPointer class holds a weak reference to a shared pointer.
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition: qevent.h:586

◆ done

void QDialog::done ( int  r)
virtualslot

Closes the dialog and sets its result code to r.

If this dialog is shown with exec(), done() causes the local event loop to finish, and exec() to return r.

As with QWidget::close(), done() deletes the dialog if the Qt::WA_DeleteOnClose flag is set. If the dialog is the application's main widget, the application terminates. If the dialog is the last window closed, the QApplication::lastWindowClosed() signal is emitted.

See also
accept(), reject(), QApplication::activeWindow(), QApplication::quit()

Reimplemented in QFileDialog, QInputDialog, QWizard, QColorDialog, QFontDialog, QPrintDialog, QPrintPreviewDialog, QErrorMessage, and QAbstractPageSetupDialog.

Definition at line 617 of file qdialog.cpp.

Referenced by accept(), QAbstractPageSetupDialog::done(), QErrorMessage::done(), QPrintPreviewDialog::done(), QPrintDialog::done(), QFontDialog::done(), QColorDialog::done(), QWizard::done(), QInputDialog::done(), QFileDialog::done(), and reject().

618 {
619  Q_D(QDialog);
620  hide();
621  setResult(r);
622 
623  d->close_helper(QWidgetPrivate::CloseNoEvent);
624  d->resetModalitySetByOpen();
625 
626  emit finished(r);
627  if (r == Accepted)
628  emit accepted();
629  else if (r == Rejected)
630  emit rejected();
631 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
void rejected()
This signal is emitted when the dialog has been rejected either by the user or by calling reject() or...
void hide()
Hides the widget.
Definition: qwidget.h:501
void setResult(int r)
Sets the modal dialog&#39;s result code to i.
Definition: qdialog.cpp:475
void accepted()
This signal is emitted when the dialog has been accepted either by the user or by calling accept() or...
void finished(int result)
This signal is emitted when the dialog&#39;s result code has been set, either by the user or by calling d...

◆ event()

bool QDialog::event ( QEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Reimplemented in QMessageBox, and QWizard.

Definition at line 426 of file qdialog.cpp.

Referenced by QMessageBox::critical(), QWizard::event(), QMessageBox::event(), and QPrintPropertiesDialog::setCups().

427 {
428  bool result = QWidget::event(e);
429 #ifdef Q_WS_WINCE
430  if (e->type() == QEvent::OkRequest) {
431  accept();
432  result = true;
433  }
434 #elif defined(Q_WS_S60)
435  if ((e->type() == QEvent::StyleChange) || (e->type() == QEvent::Resize )) {
436  if (!testAttribute(Qt::WA_Moved)) {
437  Qt::WindowStates state = windowState();
439  setAttribute(Qt::WA_Moved, false); // not really an explicit position
440  if (state != windowState())
441  setWindowState(state);
442  }
443  }
444  // TODO is Symbian, non-S60 behaviour required?
445 #endif
446  return result;
447 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
virtual void accept()
Hides the modal dialog and sets the result code to Accepted.
Definition: qdialog.cpp:639
void adjustPosition(QWidget *)
Definition: qdialog.cpp:850
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int result() const
In general returns the modal dialog&#39;s result code, Accepted or Rejected.
Definition: qdialog.cpp:458
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
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

◆ eventFilter()

bool QDialog::eventFilter ( QObject o,
QEvent e 
)
protectedvirtual

Reimplemented Function

Reimplemented from QObject.

Reimplemented in QFontDialog.

Definition at line 656 of file qdialog.cpp.

Referenced by QPrintDialogPrivate::setupOptions().

657 {
658  return QWidget::eventFilter(o, e);
659 }
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375

◆ exec

int QDialog::exec ( )
slot

Shows the dialog as a modal dialog, blocking until the user closes it.

The function returns a DialogCode result.

If the dialog is application modal, users cannot interact with any other window in the same application until they close the dialog. If the dialog is window modal, only interaction with the parent window is blocked while the dialog is open. By default, the dialog is application modal.

See also
open(), show(), result(), setWindowModality()

Definition at line 524 of file qdialog.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_btnPropertiesClicked(), QMessageBox::critical(), QColorDialog::getColor(), QInputDialog::getDouble(), QFileDialog::getExistingDirectory(), QFontDialogPrivate::getFont(), QInputDialog::getInt(), QFileDialog::getOpenFileName(), QFileDialog::getOpenFileNames(), QFileDialog::getSaveFileName(), QInputDialog::getText(), QPrintDialogPrivate::selectPrinter(), QPrintDialogPrivate::setPrinter(), and QPageSetupWidget::setRightMargin().

525 {
526  Q_D(QDialog);
527 
528  if (d->eventLoop) {
529  qWarning("QDialog::exec: Recursive call detected");
530  return -1;
531  }
532 
533  bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
535 
536  d->resetModalitySetByOpen();
537 
538  bool wasShowModal = testAttribute(Qt::WA_ShowModal);
540  setResult(0);
541 
542 //On Windows Mobile we create an empty menu to hide the current menu
543 #ifdef Q_WS_WINCE_WM
544 #ifndef QT_NO_MENUBAR
545  QMenuBar *menuBar = 0;
546  if (!findChild<QMenuBar *>())
547  menuBar = new QMenuBar(this);
548  if (qt_wince_is_smartphone()) {
549  QAction *doneAction = new QAction(tr("Done"), this);
550  menuBar->setDefaultAction(doneAction);
551  connect(doneAction, SIGNAL(triggered()), this, SLOT(_q_doneAction()));
552  }
553 #endif //QT_NO_MENUBAR
554 #endif //Q_WS_WINCE_WM
555 
556  bool showSystemDialogFullScreen = false;
557 
558 #ifdef Q_OS_SYMBIAN
559  if (qobject_cast<QFileDialog *>(this) || qobject_cast<QFontDialog *>(this) ||
560  qobject_cast<QWizard *>(this)) {
561  showSystemDialogFullScreen = true;
562  }
563 #endif // Q_OS_SYMBIAN
564 
565 #ifdef Q_OS_BLACKBERRY
566  if (!qobject_cast<QMessageBox *>(this))
567  showSystemDialogFullScreen = true;
568 #endif // Q_OS_BLACKBERRY
569 
570  if (showSystemDialogFullScreen) {
573  }
574  show();
575 
576 #ifdef Q_WS_MAC
577  d->mac_nativeDialogModalHelp();
578 #endif
579 
580  QEventLoop eventLoop;
581  d->eventLoop = &eventLoop;
582  QPointer<QDialog> guard = this;
583  (void) eventLoop.exec(QEventLoop::DialogExec);
584  if (guard.isNull())
585  return QDialog::Rejected;
586  d->eventLoop = 0;
587 
588  setAttribute(Qt::WA_ShowModal, wasShowModal);
589 
590  int res = result();
591  if (deleteOnClose)
592  delete this;
593 #ifdef Q_WS_WINCE_WM
594 #ifndef QT_NO_MENUBAR
595  else if (menuBar)
596  delete menuBar;
597 #endif //QT_NO_MENUBAR
598 #endif //Q_WS_WINCE_WM
599  return res;
600 }
double d
Definition: qnumeric_p.h:62
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
bool isNull() const
Returns true if the referenced object has been destroyed or if there is no referenced object; otherwi...
Definition: qpointer.h:70
#define SLOT(a)
Definition: qobjectdefs.h:226
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define Q_D(Class)
Definition: qglobal.h:2482
The QPointer class is a template class that provides guarded pointers to QObject. ...
Definition: qpointer.h:54
#define SIGNAL(a)
Definition: qobjectdefs.h:227
The QEventLoop class provides a means of entering and leaving an event loop.
Definition: qeventloop.h:55
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 rece...
Definition: qobject.cpp:2580
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool qt_wince_is_smartphone()
void setWindowFlags(Qt::WindowFlags type)
Definition: qwidget.cpp:10399
Q_CORE_EXPORT void qWarning(const char *,...)
void show()
Shows the widget and its child widgets.
void setDefaultAction(QAction *)
Sets the default action to act.
Definition: qmenubar.cpp:2126
void setResult(int r)
Sets the modal dialog&#39;s result code to i.
Definition: qdialog.cpp:475
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
int result() const
In general returns the modal dialog&#39;s result code, Accepted or Rejected.
Definition: qdialog.cpp:458
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
Qt::WindowFlags windowFlags() const
Window flags are a combination of a type (e.
Definition: qwidget.h:939
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
Definition: qeventloop.cpp:181
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64

◆ extension()

QWidget * QDialog::extension ( ) const

Returns the dialog's extension or 0 if no extension has been defined.

Instead of using this functionality, we recommend that you simply call show() or hide() on the part of the dialog that you want to use as an extension. See the Extension Example for details.

See also
showExtension(), setOrientation()

Definition at line 1087 of file qdialog.cpp.

Referenced by setExtension().

1088 {
1089  Q_D(const QDialog);
1090  return d->extension;
1091 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482

◆ finished

void QDialog::finished ( int  result)
signal

This signal is emitted when the dialog's result code has been set, either by the user or by calling done(), accept(), or reject().

Since
4.1

Note that this signal is not emitted when hiding the dialog with hide() or setVisible(false). This includes deleting the dialog while it is visible.

See also
accepted(), rejected()

Referenced by QPrintPreviewDialog::done(), done(), QPrintPreviewDialog::open(), and QMessageBox::open().

◆ isSizeGripEnabled()

bool QDialog::isSizeGripEnabled ( ) const

Definition at line 1224 of file qdialog.cpp.

Referenced by showExtension().

1225 {
1226 #ifndef QT_NO_SIZEGRIP
1227  Q_D(const QDialog);
1228  return !!d->resizer;
1229 #else
1230  return false;
1231 #endif
1232 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482

◆ keyPressEvent()

void QDialog::keyPressEvent ( QKeyEvent e)
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QMessageBox.

Definition at line 695 of file qdialog.cpp.

Referenced by QMessageBox::critical(), and QMessageBox::keyPressEvent().

696 {
697  // Calls reject() if Escape is pressed. Simulates a button
698  // click for the default button if Enter is pressed. Move focus
699  // for the arrow keys. Ignore the rest.
700 #ifdef Q_WS_MAC
701  if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) {
702  reject();
703  } else
704 #endif
705  if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
706  switch (e->key()) {
707  case Qt::Key_Enter:
708  case Qt::Key_Return: {
709  QList<QPushButton*> list = findChildren<QPushButton*>();
710  for (int i=0; i<list.size(); ++i) {
711  QPushButton *pb = list.at(i);
712  if (pb->isDefault() && pb->isVisible()) {
713  if (pb->isEnabled())
714  pb->click();
715  return;
716  }
717  }
718  }
719  break;
720  case Qt::Key_Escape:
721  reject();
722  break;
723  default:
724  e->ignore();
725  return;
726  }
727  } else {
728  e->ignore();
729  }
730 }
bool isVisible() const
Definition: qwidget.h:1005
virtual void reject()
Hides the modal dialog and sets the result code to Rejected.
Definition: qdialog.cpp:650
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isEnabled() const
Definition: qwidget.h:948
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool isDefault() const
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void click()
Performs a click.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ minimumSizeHint()

QSize QDialog::minimumSizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QInputDialog.

Definition at line 1186 of file qdialog.cpp.

Referenced by QInputDialog::minimumSizeHint().

1187 {
1188  Q_D(const QDialog);
1189  if (d->extension) {
1190  if (d->orientation == Qt::Horizontal)
1192  qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height()));
1193  else
1194  return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()),
1196  }
1197 
1198  return QWidget::minimumSizeHint();
1199 }
double d
Definition: qnumeric_p.h:62
virtual QSize minimumSizeHint() const
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int width() const
int height() const
Returns the height.
Definition: qsize.h:129
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ open

void QDialog::open ( )
slot

Shows the dialog as a window modal dialog, returning immediately.

Since
4.5
See also
exec(), show(), result(), setWindowModality()

Definition at line 492 of file qdialog.cpp.

Referenced by QPrintPreviewDialog::open(), QColorDialog::open(), QFontDialog::open(), QPageSetupDialog::open(), QProgressDialog::open(), QPrintDialog::open(), QMessageBox::open(), QInputDialog::open(), and QFileDialog::open().

493 {
494  Q_D(QDialog);
495 
496  Qt::WindowModality modality = windowModality();
497  if (modality != Qt::WindowModal) {
498  d->resetModalityTo = modality;
499  d->wasModalitySet = testAttribute(Qt::WA_SetWindowModality);
502 #ifdef Q_WS_MAC
504 #endif
505  }
506 
507  setResult(0);
508  show();
509 }
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
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::WindowModality windowModality() const
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
void setWindowModality(Qt::WindowModality windowModality)
Definition: qwidget.cpp:2991
void show()
Shows the widget and its child widgets.
void setResult(int r)
Sets the modal dialog&#39;s result code to i.
Definition: qdialog.cpp:475
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
WindowModality
Definition: qnamespace.h:1683

◆ orientation()

Qt::Orientation QDialog::orientation ( ) const

Returns the dialog's extension orientation.

Instead of using this functionality, we recommend that you simply call show() or hide() on the part of the dialog that you want to use as an extension. See the Extension Example for details.

See also
extension()

Definition at line 1035 of file qdialog.cpp.

Referenced by setOrientation().

1036 {
1037  Q_D(const QDialog);
1038  return d->orientation;
1039 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482

◆ reject

void QDialog::reject ( )
virtualslot

Hides the modal dialog and sets the result code to Rejected.

See also
accept() done()

Definition at line 650 of file qdialog.cpp.

Referenced by QPrintPropertiesDialog::addItemToOptions(), closeEvent(), QFontDialogPrivate::init(), keyPressEvent(), QAxSelect::QAxSelect(), and QPrintPropertiesDialog::QPrintPropertiesDialog().

651 {
652  done(Rejected);
653 }
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition: qdialog.cpp:617

◆ rejected

void QDialog::rejected ( )
signal

This signal is emitted when the dialog has been rejected either by the user or by calling reject() or done() with the QDialog::Rejected argument.

Since
4.1

Note that this signal is not emitted when hiding the dialog with hide() or setVisible(false). This includes deleting the dialog while it is visible.

See also
finished(), accepted()

Referenced by QPrintPropertiesDialog::addItemToOptions(), done(), and QFontDialogPrivate::init().

◆ resizeEvent()

void QDialog::resizeEvent ( QResizeEvent )
protectedvirtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QMessageBox, QWizard, and QProgressDialog.

Definition at line 1268 of file qdialog.cpp.

Referenced by QMessageBox::critical(), QWizard::resizeEvent(), and QMessageBox::resizeEvent().

1269 {
1270 #ifndef QT_NO_SIZEGRIP
1271  Q_D(QDialog);
1272  if (d->resizer) {
1273  if (isRightToLeft())
1274  d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1275  else
1276  d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1277  d->resizer->raise();
1278  }
1279 #endif
1280 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
QRect rect() const
bool isRightToLeft() const
Definition: qwidget.h:428

◆ result()

int QDialog::result ( ) const

In general returns the modal dialog's result code, Accepted or Rejected.

Note
When used from QMessageBox instance the result code type is QMessageBox::StandardButton

Do not call this function if the dialog was constructed with the Qt::WA_DeleteOnClose attribute.

Definition at line 458 of file qdialog.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_btnPropertiesClicked(), QMessageBoxPrivate::abstractButtonForId(), QInputDialog::comboBoxItems(), event(), QMessageBox::event(), QPageSetupDialog::exec(), QPrintDialog::exec(), QColorDialog::getRgba(), QUnixPrintWidgetPrivate::setupPrinter(), and QWizard::sizeHint().

459 {
460  Q_D(const QDialog);
461  return d->rescode;
462 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setExtension()

void QDialog::setExtension ( QWidget extension)

Sets the widget, extension, to be the dialog's extension, deleting any previous extension.

The dialog takes ownership of the extension. Note that if 0 is passed any existing extension will be deleted. This function must only be called while the dialog is hidden.

Instead of using this functionality, we recommend that you simply call show() or hide() on the part of the dialog that you want to use as an extension. See the Extension Example for details.

See also
showExtension(), setOrientation()

Definition at line 1058 of file qdialog.cpp.

1059 {
1060  Q_D(QDialog);
1061  delete d->extension;
1062  d->extension = extension;
1063 
1064  if (!extension)
1065  return;
1066 
1067  if (extension->parentWidget() != this)
1068  extension->setParent(this);
1069  extension->hide();
1070 }
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
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
QWidget * extension() const
Returns the dialog&#39;s extension or 0 if no extension has been defined.
Definition: qdialog.cpp:1087
#define Q_D(Class)
Definition: qglobal.h:2482
void hide()
Hides the widget.
Definition: qwidget.h:501

◆ setModal()

void QDialog::setModal ( bool  modal)

Definition at line 1218 of file qdialog.cpp.

Referenced by QMessageBox::setWindowModality().

1219 {
1221 }
bool modal
whether show() should pop up the dialog as modal or modeless
Definition: qdialog.h:62
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ setOrientation()

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

If orientation is Qt::Horizontal, the extension will be displayed to the right of the dialog's main area.

If orientation is Qt::Vertical, the extension will be displayed below the dialog's main area.

Instead of using this functionality, we recommend that you simply call show() or hide() on the part of the dialog that you want to use as an extension. See the Extension Example for details.

See also
setExtension()

Definition at line 1015 of file qdialog.cpp.

1016 {
1017  Q_D(QDialog);
1018  d->orientation = orientation;
1019 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
Qt::Orientation orientation() const
Returns the dialog&#39;s extension orientation.
Definition: qdialog.cpp:1035

◆ setResult()

void QDialog::setResult ( int  i)

Sets the modal dialog's result code to i.

Note
We recommend that you use one of the values defined by QDialog::DialogCode.

Definition at line 475 of file qdialog.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_btnPropertiesClicked(), QMessageBox::closeEvent(), done(), exec(), and open().

476 {
477  Q_D(QDialog);
478  d->rescode = r;
479 }
double d
Definition: qnumeric_p.h:62
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setSizeGripEnabled()

void QDialog::setSizeGripEnabled ( bool  enabled)

Definition at line 1235 of file qdialog.cpp.

Referenced by showExtension().

1236 {
1237 #ifdef QT_NO_SIZEGRIP
1238  Q_UNUSED(enabled);
1239 #else
1240  Q_D(QDialog);
1241 #ifndef QT_NO_SIZEGRIP
1242  d->sizeGripEnabled = enabled;
1243  if (enabled && d->doShowExtension)
1244  return;
1245 #endif
1246  if (!enabled != !d->resizer) {
1247  if (enabled) {
1248  d->resizer = new QSizeGrip(this);
1249  // adjustSize() processes all events, which is suboptimal
1250  d->resizer->resize(d->resizer->sizeHint());
1251  if (isRightToLeft())
1252  d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft());
1253  else
1254  d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight());
1255  d->resizer->raise();
1256  d->resizer->show();
1257  } else {
1258  delete d->resizer;
1259  d->resizer = 0;
1260  }
1261  }
1262 #endif //QT_NO_SIZEGRIP
1263 }
double d
Definition: qnumeric_p.h:62
bool enabled
whether the widget is enabled
Definition: qwidget.h:157
The QSizeGrip class provides a resize handle for resizing top-level windows.
Definition: qsizegrip.h:55
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
QRect rect() const
bool isRightToLeft() const
Definition: qwidget.h:428
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setVisible()

void QDialog::setVisible ( bool  visible)
virtual

◆ showEvent()

void QDialog::showEvent ( QShowEvent event)
protectedvirtual

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

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of windows are delivered afterwards.

Note: A widget receives spontaneous show and hide events when its mapping status is changed by the window system, e.g. a spontaneous hide event when the user minimizes the window, and a spontaneous show event when the window is restored again. After receiving a spontaneous hide event, a widget is still considered visible in the sense of isVisible().

See also
visible, event(), QShowEvent

Reimplemented from QWidget.

Reimplemented in QMessageBox, QProgressDialog, and QPrintPropertiesDialog.

Definition at line 838 of file qdialog.cpp.

Referenced by QMessageBox::critical(), QProgressDialog::showEvent(), and QMessageBox::showEvent().

839 {
840  if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) {
841  Qt::WindowStates state = windowState();
843  setAttribute(Qt::WA_Moved, false); // not really an explicit position
844  if (state != windowState())
845  setWindowState(state);
846  }
847 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
Qt::WindowStates windowState() const
Returns the current window state.
Definition: qwidget.cpp:3086
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
void adjustPosition(QWidget *)
Definition: qdialog.cpp:850
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition: qcoreevent.h:304
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087

◆ showExtension

void QDialog::showExtension ( bool  showIt)
slot

If showIt is true, the dialog's extension is shown; otherwise the extension is hidden.

Instead of using this functionality, we recommend that you simply call show() or hide() on the part of the dialog that you want to use as an extension. See the Extension Example for details.

See also
show(), setExtension(), setOrientation()

Definition at line 1109 of file qdialog.cpp.

Referenced by setVisible().

1110 {
1111  Q_D(QDialog);
1112  d->doShowExtension = showIt;
1113  if (!d->extension)
1114  return;
1116  return;
1117  if (d->extension->isVisible() == showIt)
1118  return;
1119 
1120  if (showIt) {
1121  d->size = size();
1122  d->min = minimumSize();
1123  d->max = maximumSize();
1124  if (layout())
1125  layout()->setEnabled(false);
1126  QSize s(d->extension->sizeHint()
1127  .expandedTo(d->extension->minimumSize())
1128  .boundedTo(d->extension->maximumSize()));
1129  if (d->orientation == Qt::Horizontal) {
1130  int h = qMax(height(), s.height());
1131  d->extension->setGeometry(width(), 0, s.width(), h);
1132  setFixedSize(width() + s.width(), h);
1133  } else {
1134  int w = qMax(width(), s.width());
1135  d->extension->setGeometry(0, height(), w, s.height());
1136  setFixedSize(w, height() + s.height());
1137  }
1138  d->extension->show();
1139 #ifndef QT_NO_SIZEGRIP
1140  const bool sizeGripEnabled = isSizeGripEnabled();
1141  setSizeGripEnabled(false);
1142  d->sizeGripEnabled = sizeGripEnabled;
1143 #endif
1144  } else {
1145  d->extension->hide();
1146  // workaround for CDE window manager that won't shrink with (-1,-1)
1147  setMinimumSize(d->min.expandedTo(QSize(1, 1)));
1148  setMaximumSize(d->max);
1149  resize(d->size);
1150  if (layout())
1151  layout()->setEnabled(true);
1152 #ifndef QT_NO_SIZEGRIP
1153  setSizeGripEnabled(d->sizeGripEnabled);
1154 #endif
1155  }
1156 }
double d
Definition: qnumeric_p.h:62
bool sizeGripEnabled
whether the size grip is enabled
Definition: qdialog.h:61
void setEnabled(bool)
Enables this layout if enable is true, otherwise disables it.
Definition: qlayout.cpp:1563
QSize size() const
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
void setMaximumSize(const QSize &)
Definition: qwidget.h:972
void setMinimumSize(const QSize &)
Definition: qwidget.h:969
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
int width() const
bool isSizeGripEnabled() const
Definition: qdialog.cpp:1224
void resize(int w, int h)
This corresponds to resize(QSize(w, h)).
Definition: qwidget.h:1014
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
QSize maximumSize() const
QSize minimumSize() const
void setSizeGripEnabled(bool)
Definition: qdialog.cpp:1235
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ sizeHint()

QSize QDialog::sizeHint ( ) const
virtual

Reimplemented Function

Reimplemented from QWidget.

Reimplemented in QMessageBox, QWizard, QInputDialog, and QProgressDialog.

Definition at line 1160 of file qdialog.cpp.

Referenced by QInputDialog::sizeHint(), and QMessageBox::sizeHint().

1161 {
1162  Q_D(const QDialog);
1163  if (d->extension) {
1164  if (d->orientation == Qt::Horizontal)
1165  return QSize(QWidget::sizeHint().width(),
1166  qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height()));
1167  else
1168  return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()),
1170  }
1171 #if defined(Q_WS_S60)
1172  // if size is not fixed, try to adjust it according to S60 layoutting
1173  if (minimumSize() != maximumSize()) {
1174  // In S60, dialogs are always the width of screen (in portrait, regardless of current layout)
1175  return QSize(qMin(S60->screenHeightInPixels, S60->screenWidthInPixels), QWidget::sizeHint().height());
1176  } else {
1177  return QWidget::sizeHint();
1178  }
1179 #else
1180  return QWidget::sizeHint();
1181 #endif //Q_WS_S60
1182 }
double d
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
#define Q_D(Class)
Definition: qglobal.h:2482
int height() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual QSize sizeHint() const
int width() const
QSize maximumSize() const
int height() const
Returns the height.
Definition: qsize.h:129
QSize minimumSize() const
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

Friends and Related Functions

◆ QPushButton

friend class QPushButton
friend

Properties

◆ modal

QDialog::modal
private

whether show() should pop up the dialog as modal or modeless

By default, this property is false and show() pops up the dialog as modeless. Setting his property to true is equivalent to setting QWidget::windowModality to Qt::ApplicationModal.

exec() ignores the value of this property and always pops up the dialog as modal.

See also
QWidget::windowModality, show(), exec()

Definition at line 62 of file qdialog.h.

Referenced by QDialog(), and QMessageBox::setWindowModality().

◆ sizeGripEnabled

QDialog::sizeGripEnabled
private

whether the size grip is enabled

A QSizeGrip is placed in the bottom-right corner of the dialog when this property is enabled. By default, the size grip is disabled.

Definition at line 61 of file qdialog.h.

Referenced by showExtension().


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