The QDialog class is the base class of dialog windows. More...
#include <qdialog.h>
Inherits QWidget.
Inherited by QColorDialog, QFileDialog, QFontDialog, QInputDialog, QMessageBox, QPrintDialog, QTabDialog and QWizard.
Type | Name | READ | WRITE | Options |
---|---|---|---|---|
bool | sizeGripEnabled | isSizeGripEnabled | setSizeGripEnabled |
A dialog window is a top-level window used for short-term tasks and brief communications with the user. QDialog offers mechanisms such as modality, default buttons, extensibility and a result value.
Modality means that the dialog blocks input to other windows: The user has to finish interacting with the dialog and close it before resuming work with the other window(s). The only way to set modality is by using the constructor, and the default is modelessness. For modal dialog, it's generally better to call exec() than show; exec() returns when the dialog has been closed and has a useful return value (see below).
The default button is the button that's pressed when the user presses Enter or Return, to accept the things done using this dialog and close it. QDialog uses QPushButton::autoDefault(), QPushButton::isDefault() and QPushButton::setDefault() to make Enter or Return map to the right button at any time.
Extensibility is the ability to show more or less of the dialog. Typically, the dialog starts out small, has a "More" button, and when the user clicks "More", the dialog becomes bigger, and shows some less-used options. QDialog supports this using setExtension(), setOrientation() and showExtension().
Since dialogs typically tend to have result value (pressing Enter/Return maps to one value and pressing Escape to the other), QDialog supports that. A dialog can finish by calling the slots accept() or reject(), and exec() returns that result.
Note that QDialog uses the parent widget a bit differently from other classes in Qt. A dialog is always a top-level widget, but if it has a parent, its default location is on top of the parent, it shares taskbar entry with its parent, and there are some minor details.
QDialog also can provide a QSizeGrip in its lower-right corner. If you want that, call setSizeGripEnabled( TRUE ).
See also QTabDialog, QWidget, QSemiModal and GUI Design Handbook: Dialogs, Standard.
Examples: i18n/main.cpp
Constructs a dialog named name, which has a parent widget parent.
The dialog is modal (blocks input to other windows) if modal is TRUE, and modeless if modal is FALSE (this is the default).
The widget flags f are sent to the QWidget constructor, as usual.
If you e.g. don't want a What"s this button in the titlebar of the dialog, pass WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu here.
We recommend always passing a parent.
Destructs the QDialog, deleting all its children.
[virtual protected slot]
Hides the dialog and sets the result code to Accepted.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual protected slot]
Hides the (modal) dialog and sets its result code to r. This uses the local event loop to finish and exec() to return r.
If the dialog has the WDestructiveClose
flag set, done() also
deletes the dialog.
At some future date, this function will probably close the dialog instead of hiding it. It currently calls hide() in order to avoid breaking a large number of programs that reimplement closeEvent().
See also accept() and reject().
Reimplemented in QFileDialog.
Starts the (modal) dialog, waits, and returns the result code when it is done.
If the dialog is modeless, the behaviour of this function is undefined.
Examples: wizard/main.cpp i18n/main.cpp
Returns the dialog's extension or 0 if no extension has been defined.
See also setExtension().
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns TRUE if the QDialog has a QSizeGrip in the bottom right of the dialog, and FALSE if it does not.
See also setSizeGripEnabled().
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Reimplemented for internal reasons; the API is not affected.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns the extension direction of the dialog.
See also setOrientation().
[virtual protected slot]
Hides the dialog and sets the result code to Rejected.
Reimplemented for internal reasons; the API is not affected.
Examples: tabdialog/main.cpp
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns the result code of the dialog.
Sets extension to be the dialog's extension, or deletes the extensions if extension is 0.
The dialogs takes over ownership of the extension. Any previously set extension is deleted.
This function can only be called while the dialog is hidden.
See also showExtension(), setOrientation() and extension().
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[protected]
Sets the result code of the dialog.
Enables or disables the QSizeGrip in the bottom right of the dialog. By default, the size grip is disabled.
See also isSizeGripEnabled().
[virtual]
Shows the dialog box on the screen, as QWidget::show(), and selects a suitable position and size if none has been specified yet.
Warning: In Qt 2.x, calling show() on a modal dialog enters a local event loop, and work like exec(), but not returning the result code exec() returns. Trolltech has always warned against doing this.
In Qt 3.0 and later, calling show() on a modal dialog will return immediately, not enter a local event loop. The dialog will of course be modal.
See also exec().
Examples: movies/main.cpp
Reimplemented from QWidget.
[protected slot]
Extends the dialog to show its extension if showIt is TRUE and hides it else.
This slot is usually connected to the QButton::toggled() signal of a QPushButton.
If the dialog is not visible, nothing happens.
See also show(), setExtension() and setOrientation().
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright © 2000 Trolltech | Trademarks | Qt version 2.2.1
|