#include <qdialog.h>
Inheritance diagram for QDialog:


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 (an 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).
A \bold{modal} dialog is a dialog that blocks input to other visible windows in the same application. Users must finish interacting with the dialog and close it before they can access any other window in the application. Dialogs that are used to request a file name from the user or that are used to set application preferences are usually modal. 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 \link #return return value\endlink. Typically, to get the dialog to close and return the appropriate value, we connect a default button, e.g. \gui OK, to the accept() slot and a \gui Cancel button to the reject() slot. Alternatively you can call the done() slot with \c Accepted or \c 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.) @section Modeless Dialogs A \bold{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. \target default @section Default Button A dialog's \e 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. \target escapekey @section 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 \link QCloseEvent close event \endlink cannot be \link QCloseEvent::ignore() ignored \endlink. @section 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 \gui More toggle button. If the user presses the \gui More button down, the dialog is expanded. The \l{Extension Example} shows how to achieve extensible dialogs using Qt. \target return @section 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 \gui OK or \gui Cancel. A dialog can be closed by calling the accept() or the reject() slots, and exec() will return \c Accepted or \c 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. \target examples @section Code Examples A modal dialog: \quotefunction snippets/dialogs/dialogs.cpp void EditorWindow::countWords() A modeless dialog: \quotefunction snippets/dialogs/dialogs.cpp void EditorWindow::find() \sa QDialogButtonBox, QTabDialog, QWidget, QProgressDialog, {fowler}{GUI Design Handbook: Dialogs, Standard}, {Extension Example}, {Standard Dialogs Example} Definition at line 36 of file qdialog.h.
Public Types | |
| enum | DialogCode |
Public Slots | |
| int | exec () |
| virtual void | done (int) |
| virtual void | accept () |
| virtual void | reject () |
| void | showExtension (bool) |
Signals | |
| void | finished (int result) |
| void | accepted () |
| void | rejected () |
Public Member Functions | |
| QDialog (QWidget *parent=0, Qt::WindowFlags f=0) | |
| ~QDialog () | |
| int | result () const |
| void | setVisible (bool visible) |
| void | setOrientation (Qt::Orientation orientation) |
| Qt::Orientation | orientation () const |
| void | setExtension (QWidget *extension) |
| QWidget * | extension () const |
| QSize | sizeHint () const |
| QSize | minimumSizeHint () const |
| void | setSizeGripEnabled (bool) |
| bool | isSizeGripEnabled () const |
| void | setModal (bool modal) |
| void | setResult (int r) |
Protected Member Functions | |
| QDialog (QDialogPrivate &, QWidget *parent, Qt::WindowFlags f=0) | |
| void | keyPressEvent (QKeyEvent *) |
| void | closeEvent (QCloseEvent *) |
| void | showEvent (QShowEvent *) |
| void | resizeEvent (QResizeEvent *) |
| void | contextMenuEvent (QContextMenuEvent *) |
| bool | eventFilter (QObject *, QEvent *) |
| void | adjustPosition (QWidget *) |
Friends | |
| class | QPushButton |
| enum QDialog::DialogCode |
| 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.
Definition at line 201 of file qdialog.cpp.
00202 : QWidget(*new QDialogPrivate, parent, 00203 f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 00204 { 00205 }
| QDialog::~QDialog | ( | ) |
Destroys the QDialog, deleting all its children.
Definition at line 236 of file qdialog.cpp.
References QWidget::hide().
00237 { 00238 // Need to hide() here, as our (to-be) overridden hide() 00239 // will not be called in ~QWidget. 00240 hide(); 00241 }
| 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.
Definition at line 227 of file qdialog.cpp.
00228 : QWidget(dd, parent, f | QFlag((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : 0)) 00229 { 00230 }
| int QDialog::result | ( | ) | const |
Returns the modal dialog's result code, Accepted or Rejected.
Do not call this function if the dialog was constructed with the Qt::WA_DeleteOnClose attribute.
Definition at line 345 of file qdialog.cpp.
References d.
Referenced by qdesigner_internal::PromoteToCustomWidgetDialog::accept(), exec(), NewForm::formPreviewIcon(), QColorDialog::getColor(), QFileDialog::getExistingDirectory(), Q3FileDialog::getExistingDirectory(), QFileDialog::getOpenFileName(), Q3FileDialog::getOpenFileName(), Q3FileDialog::getOpenFileNames(), QFileDialog::getOpenFileNames(), qdesigner_internal::PaletteEditor::getPalette(), PaletteEditorAdvanced::getPalette(), QColorDialog::getRgba(), Q3FileDialog::getSaveFileName(), QFileDialog::getSaveFileName(), QInputDialog::getText(), and Calculator::unaryOperatorClicked().
| void QDialog::setVisible | ( | bool | visible | ) | [virtual] |
Reimplemented from QWidget.
Definition at line 598 of file qdialog.cpp.
References adjustPosition(), QPushButton::autoDefault(), d, QAccessible::DialogEnd, QAccessible::DialogStart, QEvent::FocusIn, QWidget::focusPolicy(), QWidget::focusWidget(), QWidget::hasFocus(), QWidget::isVisible(), QWidget::isWindow(), Qt::NoFocus, QWidget::parentWidget(), QCoreApplication::sendEvent(), QWidget::setAttribute(), QPushButton::setDefault(), QWidget::setVisible(), QWidget::setWindowState(), showExtension(), Qt::TabFocusReason, QWidget::testAttribute(), QAccessible::updateAccessibility(), w, Qt::WA_Moved, QWidget::window(), and QWidget::windowState().
Referenced by ChatMainWindow::ChatMainWindow(), and Q3Wizard::setVisible().
00599 { 00600 Q_D(QDialog); 00601 if (visible) { 00602 if (isVisible()) 00603 return; 00604 00605 #ifdef Q_OS_TEMP 00606 hideSpecial(); 00607 #endif 00608 00609 if (!testAttribute(Qt::WA_Moved)) { 00610 Qt::WindowStates state = windowState(); 00611 adjustPosition(parentWidget()); 00612 setAttribute(Qt::WA_Moved, false); // not really an explicit position 00613 if (state != windowState()) 00614 setWindowState(state); 00615 } 00616 QWidget::setVisible(visible); 00617 showExtension(d->doShowExtension); 00618 QWidget *fw = window()->focusWidget(); 00619 if (!fw) 00620 fw = this; 00621 00622 /* 00623 The following block is to handle a special case, and does not 00624 really follow propper logic in concern of autoDefault and TAB 00625 order. However, it's here to ease usage for the users. If a 00626 dialog has a default QPushButton, and first widget in the TAB 00627 order also is a QPushButton, then we give focus to the main 00628 default QPushButton. This simplifies code for the developers, 00629 and actually catches most cases... If not, then they simply 00630 have to use [widget*]->setFocus() themselves... 00631 */ 00632 if (d->mainDef && fw->focusPolicy() == Qt::NoFocus) { 00633 QWidget *first = fw; 00634 while ((first = first->nextInFocusChain()) != fw && first->focusPolicy() == Qt::NoFocus) 00635 ; 00636 if (first != d->mainDef && qobject_cast<QPushButton*>(first)) 00637 d->mainDef->setFocus(); 00638 } 00639 if (!d->mainDef && isWindow()) { 00640 QWidget *w = fw; 00641 while ((w = w->nextInFocusChain()) != fw) { 00642 QPushButton *pb = qobject_cast<QPushButton *>(w); 00643 if (pb && pb->autoDefault() && pb->focusPolicy() != Qt::NoFocus) { 00644 pb->setDefault(true); 00645 break; 00646 } 00647 } 00648 } 00649 if (fw && !fw->hasFocus()) { 00650 QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason); 00651 QApplication::sendEvent(fw, &e); 00652 } 00653 00654 #ifndef QT_NO_ACCESSIBILITY 00655 QAccessible::updateAccessibility(this, 0, QAccessible::DialogStart); 00656 #endif 00657 00658 } else { 00659 if (!isVisible()) 00660 return; 00661 00662 #ifndef QT_NO_ACCESSIBILITY 00663 if (isVisible()) 00664 QAccessible::updateAccessibility(this, 0, QAccessible::DialogEnd); 00665 #endif 00666 00667 // Reimplemented to exit a modal event loop when the dialog is hidden. 00668 QWidget::setVisible(visible); 00669 if (d->eventLoop) 00670 d->eventLoop->exit(); 00671 } 00672 }
Here is the call graph for this function:

| 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.
Definition at line 779 of file qdialog.cpp.
References d.
00780 { 00781 Q_D(QDialog); 00782 d->orientation = orientation; 00783 }
| 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.
Definition at line 796 of file qdialog.cpp.
References d.
Referenced by Dialog::buttonsOrientationChanged(), and updateLastSize().
| 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.
Definition at line 816 of file qdialog.cpp.
References d, extension(), QWidget::hide(), QWidget::parentWidget(), and QWidget::setParent().
00817 { 00818 Q_D(QDialog); 00819 delete d->extension; 00820 d->extension = extension; 00821 00822 if (!extension) 00823 return; 00824 00825 if (extension->parentWidget() != this) 00826 extension->setParent(this); 00827 extension->hide(); 00828 }
Here is the call graph for this function:

| 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.
Definition at line 842 of file qdialog.cpp.
References d.
Referenced by setExtension(), and updateLastSize().
| QSize QDialog::sizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 904 of file qdialog.cpp.
References d, QWidget::height(), Qt::Horizontal, qMax(), QWidget::sizeHint(), and QWidget::width().
Referenced by RegExpDialog::RegExpDialog(), and QMessageBox::sizeHint().
00905 { 00906 Q_D(const QDialog); 00907 if (d->extension) 00908 if (d->orientation == Qt::Horizontal) 00909 return QSize(QWidget::sizeHint().width(), 00910 qMax(QWidget::sizeHint().height(),d->extension->sizeHint().height())); 00911 else 00912 return QSize(qMax(QWidget::sizeHint().width(), d->extension->sizeHint().width()), 00913 QWidget::sizeHint().height()); 00914 00915 return QWidget::sizeHint(); 00916 }
Here is the call graph for this function:

| QSize QDialog::minimumSizeHint | ( | ) | const [virtual] |
Reimplemented from QWidget.
Definition at line 920 of file qdialog.cpp.
References d, QWidget::height(), Qt::Horizontal, QWidget::minimumSizeHint(), qMax(), and QWidget::width().
00921 { 00922 Q_D(const QDialog); 00923 if (d->extension) 00924 if (d->orientation == Qt::Horizontal) 00925 return QSize(QWidget::minimumSizeHint().width(), 00926 qMax(QWidget::minimumSizeHint().height(), d->extension->minimumSizeHint().height())); 00927 else 00928 return QSize(qMax(QWidget::minimumSizeHint().width(), d->extension->minimumSizeHint().width()), 00929 QWidget::minimumSizeHint().height()); 00930 00931 return QWidget::minimumSizeHint(); 00932 }
Here is the call graph for this function:

| void QDialog::setSizeGripEnabled | ( | bool | ) |
Definition at line 965 of file qdialog.cpp.
References d, QWidget::isRightToLeft(), and QWidget::rect().
Referenced by Q3FileDialog::init(), QColorDialog::QColorDialog(), and QFontDialog::QFontDialog().
00966 { 00967 #ifdef QT_NO_SIZEGRIP 00968 Q_UNUSED(enabled); 00969 #else 00970 Q_D(QDialog); 00971 if (!enabled != !d->resizer) { 00972 if (enabled) { 00973 d->resizer = new QSizeGrip(this); 00974 // adjustSize() processes all events, which is suboptimal 00975 d->resizer->resize(d->resizer->sizeHint()); 00976 if (isRightToLeft()) 00977 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft()); 00978 else 00979 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight()); 00980 d->resizer->lower(); 00981 d->resizer->show(); 00982 } else { 00983 delete d->resizer; 00984 d->resizer = 0; 00985 } 00986 } 00987 #endif //QT_NO_SIZEGRIP 00988 }
Here is the call graph for this function:

| bool QDialog::isSizeGripEnabled | ( | ) | const |
Definition at line 954 of file qdialog.cpp.
References d.
00955 { 00956 #ifndef QT_NO_SIZEGRIP 00957 Q_D(const QDialog); 00958 return !!d->resizer; 00959 #else 00960 return false; 00961 #endif 00962 }
| void QDialog::setModal | ( | bool | modal | ) |
Definition at line 948 of file qdialog.cpp.
References QWidget::setAttribute(), and Qt::WA_ShowModal.
Referenced by Config::Config(), QFileDialog::getExistingDirectory(), QFileDialog::getOpenFileName(), QFileDialog::getOpenFileNames(), QFileDialog::getSaveFileName(), PhraseBookBox::PhraseBookBox(), qdesigner_internal::PromoteToCustomWidgetDialog::PromoteToCustomWidgetDialog(), Q3ProgressDialog::Q3ProgressDialog(), QColorDialog::QColorDialog(), and QFontDialog::QFontDialog().
00949 { 00950 setAttribute(Qt::WA_ShowModal, modal); 00951 }
Here is the call graph for this function:

| void QDialog::setResult | ( | int | i | ) |
Sets the modal dialog's result code to i.
Definition at line 356 of file qdialog.cpp.
References d.
Referenced by QMessageBox::closeEvent(), done(), and exec().
| void QDialog::finished | ( | int | result | ) | [signal] |
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.
Referenced by done(), and Q3FileDialog::init().
| void QDialog::accepted | ( | ) | [signal] |
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.
Referenced by FindFileDialog::createButtons(), DetailsDialog::DetailsDialog(), Dialog::Dialog(), done(), QInputDialog::getDouble(), QInputDialog::getInteger(), QInputDialog::getItem(), QInputDialog::getText(), LocationDialog::LocationDialog(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), PreviewForm::PreviewForm(), QFontDialog::QFontDialog(), qdesigner_internal::StyleSheetEditorDialog::StyleSheetEditorDialog(), TabDialog::TabDialog(), and TicTacToeDialog::TicTacToeDialog().
| void QDialog::rejected | ( | ) | [signal] |
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.
Referenced by FindFileDialog::createButtons(), DetailsDialog::DetailsDialog(), Dialog::Dialog(), done(), LocationDialog::LocationDialog(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), PreviewForm::PreviewForm(), QFontDialog::QFontDialog(), qdesigner_internal::StyleSheetEditorDialog::StyleSheetEditorDialog(), TabDialog::TabDialog(), and TicTacToeDialog::TicTacToeDialog().
| int QDialog::exec | ( | ) | [slot] |
Shows the dialog as a {QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it. The function returns a DialogCode result.
Users cannot interact with any other window in the same application until they close the dialog.
Definition at line 374 of file qdialog.cpp.
References d, QEventLoop::exec(), qWarning(), result(), QWidget::setAttribute(), setResult(), QWidget::show(), QWidget::testAttribute(), Qt::WA_DeleteOnClose, and Qt::WA_ShowModal.
Referenced by QPrintDialogPrivate::_q_btnPropertiesClicked(), MainWindow::about(), TrWindow::about(), QMessageBox::about(), QDesignerActions::aboutDesigner(), QDesignerActions::aboutPlugins(), QMessageBox::aboutQt(), MainWindow::acceptFileDrop(), Browser::addConnection(), MainWindow::addTorrent(), ChatMainWindow::changeNickname(), QDesignerToolBox::changeOrder(), QDesignerStackedWidget::changeOrder(), qdesigner_internal::QDesignerTaskMenu::changeRichTextProperty(), ColorDock::changeSizeHints(), qdesigner_internal::QDesignerTaskMenu::changeStyleSheet(), ChatMainWindow::ChatMainWindow(), QDesignerFormWindow::closeEvent(), QVFb::configure(), FtpWindow::downloadFile(), qdesigner_internal::ActionEditor::editAction(), TicTacToeTaskMenu::editState(), QPrintDialog::exec(), QPageSetupDialog::exec(), QColorDialog::getColor(), QInputDialog::getDouble(), QFileDialog::getExistingDirectory(), Q3FileDialog::getExistingDirectory(), QFontDialogPrivate::getFont(), QInputDialog::getInteger(), QInputDialog::getItem(), TopicChooser::getLink(), QFileDialog::getOpenFileName(), Q3FileDialog::getOpenFileNames(), QFileDialog::getOpenFileNames(), qdesigner_internal::PaletteEditor::getPalette(), PaletteEditorAdvanced::getPalette(), QColorDialog::getRgba(), Q3FileDialog::getSaveFileName(), QFileDialog::getSaveFileName(), qdesigner_internal::StringListEditor::getStringList(), QInputDialog::getText(), QDesignerWorkbench::handleClose(), MainWindow::helpAbout(), main(), MainWindow::on_actionAboutApplication_triggered(), qdesigner_internal::NewActionDialog::on_iconButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_previewPixmapColumnButton_clicked(), qdesigner_internal::TableWidgetEditor::on_previewPixmapColumnButton_clicked(), qdesigner_internal::TableWidgetEditor::on_previewPixmapItemButton_clicked(), qdesigner_internal::TreeWidgetEditor::on_previewPixmapItemButton_clicked(), qdesigner_internal::ListWidgetEditor::on_previewPixmapItemButton_clicked(), qdesigner_internal::TableWidgetEditor::on_previewPixmapRowButton_clicked(), MainWindow::on_printPreviewAction_triggered(), MainWindow::open(), MainWindow::openDialog(), MainWindow::openSettings(), qdesigner_internal::QDesignerTaskMenu::promoteToCustomWidget(), SpreadSheet::runInputDialog(), TrWindow::showBatchTranslateDialog(), qdesigner_internal::GraphicsPropertyEditor::showDialog(), QDesignerActions::showFormSettings(), Oubliette::showInventoryItem(), showNewMessageBox(), QMessageBoxPrivate::showOldMessageBox(), TrWindow::showTranslationSettings(), qdesigner_internal::QtBrushEditorPrivate::slotGradientChooserClicked(), qdesigner_internal::ActionEditor::slotNewAction(), qdesigner_internal::QtBrushEditorPrivate::slotPatternChooserClicked(), and Dialog::warningMessage().
00375 { 00376 Q_D(QDialog); 00377 if (d->eventLoop) { 00378 qWarning("QDialog::exec: Recursive call detected"); 00379 return -1; 00380 } 00381 00382 bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose); 00383 setAttribute(Qt::WA_DeleteOnClose, false); 00384 00385 bool wasShowModal = testAttribute(Qt::WA_ShowModal); 00386 setAttribute(Qt::WA_ShowModal, true); 00387 setResult(0); 00388 00389 show(); 00390 00391 QEventLoop eventLoop; 00392 d->eventLoop = &eventLoop; 00393 (void) eventLoop.exec(); 00394 d->eventLoop = 0; 00395 00396 setAttribute(Qt::WA_ShowModal, wasShowModal); 00397 00398 int res = result(); 00399 if (deleteOnClose) 00400 delete this; 00401 return res; 00402 }
| void QDialog::done | ( | int | r | ) | [virtual, slot] |
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.
Definition at line 418 of file qdialog.cpp.
References Accepted, accepted(), QWidgetPrivate::CloseNoEvent, d, emit, finished(), QWidget::hide(), rejected(), Rejected, and setResult().
Referenced by accept(), QErrorMessage::done(), QFileDialog::done(), Q3FileDialog::done(), and reject().
00419 { 00420 Q_D(QDialog); 00421 hide(); 00422 setResult(r); 00423 d->close_helper(QWidgetPrivate::CloseNoEvent); 00424 emit finished(r); 00425 if (r == Accepted) 00426 emit accepted(); 00427 else if (r == Rejected) 00428 emit rejected(); 00429 }
| void QDialog::accept | ( | ) | [virtual, slot] |
Hides the modal dialog and sets the result code to Accepted.
Definition at line 437 of file qdialog.cpp.
References Accepted, and done().
Referenced by qdesigner_internal::FindIconDialog::accept(), QFileDialog::accept(), FormWindowSettings::accept(), qdesigner_internal::OrderDialog::accept(), qdesigner_internal::PromoteToCustomWidgetDialog::accept(), qdesigner_internal::NewActionDialog::accept(), PreviewDialog::accept(), SaveFormAsTemplate::accept(), Config::Config(), Dialog::createMenu(), Dialog::Dialog(), QFontDialog::eventFilter(), Q3FileDialog::fileNameEditReturnPressed(), LocationDialog::LocationDialog(), QVFbRateDialog::ok(), Q3FileDialog::okClicked(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), TranslationSettingsDialog::on_buttonBox_accepted(), TopicChooser::on_buttonDisplay_clicked(), TopicChooser::on_listbox_itemActivated(), QSqlConnectionDialog::on_okButton_clicked(), PaletteEditorAdvancedBase::PaletteEditorAdvancedBase(), PhraseBookBox::PhraseBookBox(), PreviewForm::PreviewForm(), Q3TabDialog::Q3TabDialog(), Q3Wizard::Q3Wizard(), QErrorMessage::QErrorMessage(), QFontDialog::QFontDialog(), QPageSetupDialog::QPageSetupDialog(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), TicTacToeDialog::saveState(), Q3FileDialog::selectDirectoryOrFile(), qdesigner_internal::StyleSheetEditorDialog::StyleSheetEditorDialog(), TabDialog::TabDialog(), DetailsDialog::verify(), and VersionDialog::VersionDialog().
| void QDialog::reject | ( | ) | [virtual, slot] |
Hides the modal dialog and sets the result code to Rejected.
Definition at line 448 of file qdialog.cpp.
References done(), and Rejected.
Referenced by BatchTranslationDialog::BatchTranslationDialog(), QVFbRateDialog::cancel(), Q3FileDialog::cancelClicked(), closeEvent(), Config::Config(), FindFileDialog::createButtons(), DetailsDialog::DetailsDialog(), Dialog::Dialog(), keyPressEvent(), LocationDialog::LocationDialog(), qdesigner_internal::OldSignalSlotDialog::OldSignalSlotDialog(), TopicChooser::on_buttonCancel_clicked(), QSqlConnectionDialog::on_cancelButton_clicked(), PaletteEditorAdvancedBase::PaletteEditorAdvancedBase(), PreviewForm::PreviewForm(), Q3Wizard::Q3Wizard(), QFontDialog::QFontDialog(), QPageSetupDialog::QPageSetupDialog(), PreviewDialog::reject(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), Q3TabDialog::setCancelButton(), qdesigner_internal::StyleSheetEditorDialog::StyleSheetEditorDialog(), TabDialog::TabDialog(), TicTacToeDialog::TicTacToeDialog(), DetailsDialog::verify(), and VersionDialog::VersionDialog().
| 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.
Definition at line 861 of file qdialog.cpp.
References d, h, QWidget::height(), Qt::Horizontal, QWidget::layout(), QWidget::maximumSize(), QWidget::minimumSize(), qMax(), QWidget::resize(), s, QLayout::setEnabled(), QWidget::setFixedSize(), QWidget::setMaximumSize(), QWidget::setMinimumSize(), QWidget::size(), QWidget::testAttribute(), w, Qt::WA_WState_Visible, and QWidget::width().
Referenced by setVisible().
00862 { 00863 Q_D(QDialog); 00864 d->doShowExtension = showIt; 00865 if (!d->extension) 00866 return; 00867 if (!testAttribute(Qt::WA_WState_Visible)) 00868 return; 00869 if (d->extension->isVisible() == showIt) 00870 return; 00871 00872 if (showIt) { 00873 d->size = size(); 00874 d->min = minimumSize(); 00875 d->max = maximumSize(); 00876 if (layout()) 00877 layout()->setEnabled(false); 00878 QSize s(d->extension->sizeHint() 00879 .expandedTo(d->extension->minimumSize()) 00880 .boundedTo(d->extension->maximumSize())); 00881 if (d->orientation == Qt::Horizontal) { 00882 int h = qMax(height(), s.height()); 00883 d->extension->setGeometry(width(), 0, s.width(), h); 00884 setFixedSize(width() + s.width(), h); 00885 } else { 00886 int w = qMax(width(), s.width()); 00887 d->extension->setGeometry(0, height(), w, s.height()); 00888 setFixedSize(w, height() + s.height()); 00889 } 00890 d->extension->show(); 00891 } else { 00892 d->extension->hide(); 00893 // workaround for CDE window manager that won't shrink with (-1,-1) 00894 setMinimumSize(d->min.expandedTo(QSize(1, 1))); 00895 setMaximumSize(d->max); 00896 resize(d->size); 00897 if (layout()) 00898 layout()->setEnabled(true); 00899 } 00900 }
| void QDialog::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 490 of file qdialog.cpp.
References QList< T >::at(), QAbstractButton::click(), Qt::ControlModifier, QWidget::focusNextPrevChild(), QWidget::focusPolicy(), QWidget::focusWidget(), i, QEvent::ignore(), QKeyEvent::key(), Qt::Key_Down, Qt::Key_Enter, Qt::Key_Escape, Qt::Key_Left, Qt::Key_Period, Qt::Key_Return, Qt::Key_Right, Qt::Key_Up, Qt::KeypadModifier, QKeyEvent::modifiers(), reject(), QList< T >::size(), Qt::StrongFocus, and Qt::WheelFocus.
Referenced by PhraseBookBox::keyPressEvent(), QMessageBox::keyPressEvent(), and Q3FileDialog::keyPressEvent().
00491 { 00492 // Calls reject() if Escape is pressed. Simulates a button 00493 // click for the default button if Enter is pressed. Move focus 00494 // for the arrow keys. Ignore the rest. 00495 #ifdef Q_WS_MAC 00496 if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) { 00497 reject(); 00498 } else 00499 #endif 00500 if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { 00501 switch (e->key()) { 00502 case Qt::Key_Enter: 00503 case Qt::Key_Return: { 00504 QList<QPushButton*> list = qFindChildren<QPushButton*>(this); 00505 for (int i=0; i<list.size(); ++i) { 00506 QPushButton *pb = list.at(i); 00507 if (pb->isDefault() && pb->isVisible()) { 00508 if (pb->isEnabled()) 00509 pb->click(); 00510 return; 00511 } 00512 } 00513 } 00514 break; 00515 case Qt::Key_Escape: 00516 reject(); 00517 break; 00518 case Qt::Key_Up: 00519 case Qt::Key_Left: 00520 if (focusWidget() && 00521 (focusWidget()->focusPolicy() == Qt::StrongFocus || 00522 focusWidget()->focusPolicy() == Qt::WheelFocus)) { 00523 e->ignore(); 00524 break; 00525 } 00526 // call ours, since c++ blocks us from calling the one 00527 // belonging to focusWidget(). 00528 focusNextPrevChild(false); 00529 break; 00530 case Qt::Key_Down: 00531 case Qt::Key_Right: 00532 if (focusWidget() && 00533 (focusWidget()->focusPolicy() == Qt::StrongFocus || 00534 focusWidget()->focusPolicy() == Qt::WheelFocus)) { 00535 e->ignore(); 00536 break; 00537 } 00538 focusNextPrevChild(true); 00539 break; 00540 default: 00541 e->ignore(); 00542 return; 00543 } 00544 } else { 00545 e->ignore(); 00546 } 00547 }
Here is the call graph for this function:

| void QDialog::closeEvent | ( | QCloseEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 550 of file qdialog.cpp.
References QEvent::accept(), QWhatsThis::inWhatsThisMode(), QWidget::isModal(), QWidget::isVisible(), QWhatsThis::leaveWhatsThisMode(), and reject().
Referenced by ItemDialog::closeEvent(), QMessageBox::closeEvent(), Q3ProgressDialog::closeEvent(), and QProgressDialog::closeEvent().
00551 { 00552 #ifndef QT_NO_WHATSTHIS 00553 if (isModal() && QWhatsThis::inWhatsThisMode()) 00554 QWhatsThis::leaveWhatsThisMode(); 00555 #endif 00556 if (isVisible()) 00557 reject(); 00558 else 00559 e->accept(); 00560 }
Here is the call graph for this function:

| void QDialog::showEvent | ( | QShowEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 675 of file qdialog.cpp.
References adjustPosition(), QWidget::event(), QWidget::parentWidget(), QWidget::setAttribute(), QWidget::setWindowState(), QWidget::testAttribute(), Qt::WA_Moved, and QWidget::windowState().
Referenced by QMessageBox::showEvent(), Q3ProgressDialog::showEvent(), and QProgressDialog::showEvent().
00676 { 00677 if (!event->spontaneous() && !testAttribute(Qt::WA_Moved)) { 00678 Qt::WindowStates state = windowState(); 00679 adjustPosition(parentWidget()); 00680 setAttribute(Qt::WA_Moved, false); // not really an explicit position 00681 if (state != windowState()) 00682 setWindowState(state); 00683 } 00684 }
Here is the call graph for this function:

| void QDialog::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 993 of file qdialog.cpp.
References d, QWidget::isRightToLeft(), and QWidget::rect().
Referenced by Q3TabDialog::resizeEvent(), QMessageBox::resizeEvent(), and Q3FileDialog::resizeEvent().
00994 { 00995 #ifndef QT_NO_SIZEGRIP 00996 Q_D(QDialog); 00997 if (d->resizer) { 00998 if (isRightToLeft()) 00999 d->resizer->move(rect().bottomLeft() -d->resizer->rect().bottomLeft()); 01000 else 01001 d->resizer->move(rect().bottomRight() -d->resizer->rect().bottomRight()); 01002 d->resizer->lower(); 01003 } 01004 #endif 01005 }
Here is the call graph for this function:

| void QDialog::contextMenuEvent | ( | QContextMenuEvent * | e | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 464 of file qdialog.cpp.
References QWidget::childAt(), QRect::contains(), QContextMenuEvent::globalPos(), p, QContextMenuEvent::pos(), QWidget::rect(), QCoreApplication::sendEvent(), w, Qt::WA_CustomWhatsThis, and QEvent::WhatsThis.
00465 { 00466 #if defined(QT_NO_WHATSTHIS) || defined(QT_NO_MENU) 00467 Q_UNUSED(e); 00468 #else 00469 QWidget *w = childAt(e->pos()); 00470 if (!w) { 00471 w = rect().contains(e->pos()) ? this : 0; 00472 if (!w) 00473 return; 00474 } 00475 while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis)) 00476 w = w->isWindow() ? 0 : w->parentWidget(); 00477 if (w) { 00478 QMenu p; 00479 QAction *wt = p.addAction(tr("What's This?")); 00480 if (p.exec(e->globalPos()) == wt) { 00481 QHelpEvent e(QEvent::WhatsThis, w->rect().center(), 00482 w->mapToGlobal(w->rect().center())); 00483 QApplication::sendEvent(w, &e); 00484 } 00485 } 00486 #endif 00487 }
Here is the call graph for this function:

Reimplemented from QObject.
Definition at line 454 of file qdialog.cpp.
References QObject::eventFilter(), and o.
Referenced by Q3FileDialog::eventFilter(), Q3Wizard::eventFilter(), Calculator::eventFilter(), and QFontDialog::eventFilter().
00455 { 00456 return QWidget::eventFilter(o, e); 00457 }
Here is the call graph for this function:

| void QDialog::adjustPosition | ( | QWidget * | ) | [protected] |
Definition at line 687 of file qdialog.cpp.
References QList< T >::at(), ATOM, QDesktopWidget::availableGeometry(), QApplication::desktop(), QWidget::geometry(), QWidget::height(), QRect::height(), i, QWidget::move(), p, QCursor::pos(), qMax(), qt_net_supports(), QDesktopWidget::screenNumber(), QList< T >::size(), QApplication::topLevelWidgets(), w, QRect::width(), QWidget::width(), QRect::x(), QPoint::x(), QRect::y(), and QPoint::y().
Referenced by setVisible(), and showEvent().
00688 { 00689 #ifdef Q_WS_X11 00690 // defined in qapplication_x11.cpp 00691 extern bool qt_net_supports(Atom atom); 00692 00693 // if the WM advertises that it will place the windows properly for us, let it do it :) 00694 if (qt_net_supports(ATOM(_NET_WM_FULL_PLACEMENT))) 00695 return; 00696 #endif 00697 00698 QPoint p(0, 0); 00699 int extraw = 0, extrah = 0, scrn = 0; 00700 if (w) 00701 w = w->window(); 00702 QRect desk; 00703 if (w) { 00704 scrn = QApplication::desktop()->screenNumber(w); 00705 } else if (QApplication::desktop()->isVirtualDesktop()) { 00706 scrn = QApplication::desktop()->screenNumber(QCursor::pos()); 00707 } else { 00708 scrn = QApplication::desktop()->screenNumber(this); 00709 } 00710 desk = QApplication::desktop()->availableGeometry(scrn); 00711 00712 QWidgetList list = QApplication::topLevelWidgets(); 00713 for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) { 00714 QWidget * current = list.at(i); 00715 if (current->isVisible()) { 00716 int framew = current->geometry().x() - current->x(); 00717 int frameh = current->geometry().y() - current->y(); 00718 00719 extraw = qMax(extraw, framew); 00720 extrah = qMax(extrah, frameh); 00721 } 00722 } 00723 00724 // sanity check for decoration frames. With embedding, we 00725 // might get extraordinary values 00726 if (extraw == 0 || extrah == 0 || extraw >= 10 || extrah >= 40) { 00727 extrah = 40; 00728 extraw = 10; 00729 } 00730 00731 #ifndef Q_OS_TEMP 00732 if (w) { 00733 // Use mapToGlobal rather than geometry() in case w might 00734 // be embedded in another application 00735 QPoint pp = w->mapToGlobal(QPoint(0,0)); 00736 p = QPoint(pp.x() + w->width()/2, 00737 pp.y() + w->height()/ 2); 00738 } else { 00739 // p = middle of the desktop 00740 p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2); 00741 } 00742 #else 00743 p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2); 00744 #endif 00745 00746 // p = origin of this 00747 p = QPoint(p.x()-width()/2 - extraw, 00748 p.y()-height()/2 - extrah); 00749 00750 00751 if (p.x() + extraw + width() > desk.x() + desk.width()) 00752 p.setX(desk.x() + desk.width() - width() - extraw); 00753 if (p.x() < desk.x()) 00754 p.setX(desk.x()); 00755 00756 if (p.y() + extrah + height() > desk.y() + desk.height()) 00757 p.setY(desk.y() + desk.height() - height() - extrah); 00758 if (p.y() < desk.y()) 00759 p.setY(desk.y()); 00760 00761 move(p); 00762 }
Here is the call graph for this function:

friend class QPushButton [friend] |
Definition at line 40 of file qdialog.h.
Referenced by QMessageBox::addButton(), BlockingClient::BlockingClient(), Client::Client(), ConfigDialog::ConfigDialog(), Window::createButton(), Dialog::createHorizontalGroupBox(), Window::createMessageGroupBox(), Window::createPushButtonGroup(), WidgetGallery::createTopRightGroupBox(), Dialog::Dialog(), FtpWindow::FtpWindow(), HttpWindow::HttpWindow(), Q3FileDialog::init(), ItemDialog::ItemDialog(), PluginDialog::PluginDialog(), Q3TabDialog::Q3TabDialog(), Q3Wizard::Q3Wizard(), QErrorMessage::QErrorMessage(), QFDProgressDialog::QFDProgressDialog(), QPageSetupDialog::QPageSetupDialog(), QVFbRateDialog::QVFbRateDialog(), Receiver::Receiver(), qdesigner_internal::RichTextEditorDialog::RichTextEditorDialog(), Sender::Sender(), Server::Server(), Q3TabDialog::setApplyButton(), Q3TabDialog::setCancelButton(), Q3ProgressDialog::setCancelButtonText(), QProgressDialog::setCancelButtonText(), Q3TabDialog::setDefaultButton(), QMessageBox::setDetailedText(), Q3TabDialog::setHelpButton(), Q3TabDialog::setOkButton(), TableEditor::TableEditor(), and VersionDialog::VersionDialog().
1.5.1