![]() |
| ||
Classes - Annotated - Tree - Functions - Home - Structure |
The QDialog class is the base class of dialog windows. More...
#include <qdialog.h>
Inherits QWidget.
Inherited by QColorDialog, QErrorMessage, QFileDialog, QFontDialog, QInputDialog, QMessageBox, QPrintDialog, QProgressDialog, QTabDialog and QWizard.
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). You achieve this by calling exec() rather than show(); exec() returns when the dialog has been closed and has a useful return value (see below). Alternatively, you can request modality in the constructor. In that case, the dialog will always block input to other windows when being visible.
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..
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.
See also QWidget::setWFlags and Qt::WidgetFlags.
If the dialog has the WDestructiveClose flag set, done() also deletes the dialog. If the dialog is the applications's main widget, the application quits.
See also accept(), reject(), QApplication::mainWidget() and QApplication::quit().
Example: movies/main.cpp.
A dialog started with exec() is always modal, i.e. the user has to finish interacting with the dialog and close it before resuming work with the other window(s).
If you want to show a non-modal dialog, call show().
Examples: i18n/main.cpp, qdir/qdir.cpp, showimg/showimg.cpp and wizard/main.cpp.
See also setExtension().
Returns TRUE whether the size grip is enabled, otherwise returns FALSE. See the "sizeGripEnabled" property for details.
See also setOrientation().
Returns the result code of the dialog.
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().
See also orientation() and setExtension().
Sets the result code of the dialog.
Sets whether the size grip is enabled. See the "sizeGripEnabled" property for details.
Warning:
In Qt 2.x, calling show() on a modal dialog enters a local event loop, and works 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, showimg/showimg.cpp, sql/overview/form1/main.cpp and tabdialog/main.cpp.
Reimplemented from QWidget.
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().
This property holds 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.
Set this property's value with setSizeGripEnabled() and get this property's value with isSizeGripEnabled().
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 main-beta1
|