Logo Search packages:      
Sourcecode: qt4-x11 version File versions

int QDialog::exec (  )  [slot, inherited]

Shows the dialog as a {QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it. The function returns a DialogCode result.

If the dialog is {Qt::ApplicationModal}{application modal}, users cannot interact with any other window in the same application until they close the dialog. If the dialog is {Qt::ApplicationModal}{window modal}, only interaction with the parent window is blocked while the dialog is open.

By default, the dialog is application modal.

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

Reimplemented in QAbstractPageSetupDialog, QAbstractPrintDialog, QPageSetupDialog, and QPrintDialog.

Definition at line 419 of file qdialog.cpp.

References QObject::connect(), QEventLoop::exec(), QPointer< T >::isNull(), QDialog::result(), QWidget::setAttribute(), QDialog::setResult(), QWidget::show(), and QWidget::testAttribute().

Referenced by QMessageBox::about(), MainWindow::aboutPlugins(), QMessageBox::aboutQt(), AddressWidget::addEntry(), NewAddressTab::addEntry(), AddressWidget::editEntry(), TicTacToeTaskMenu::editState(), QPrintDialog::exec(), QPageSetupDialog::exec(), AddressBook::findContact(), QColorDialog::getColor(), QInputDialog::getDouble(), QFileDialog::getExistingDirectory(), Q3FileDialog::getExistingDirectory(), QtGradientDialog::getGradient(), QInputDialog::getInteger(), QInputDialog::getItem(), QFileDialog::getOpenFileName(), Q3FileDialog::getOpenFileName(), Q3FileDialog::getOpenFileNames(), QFileDialog::getOpenFileNames(), QColorDialog::getRgba(), Q3FileDialog::getSaveFileName(), QFileDialog::getSaveFileName(), QInputDialog::getText(), MainWindow::open(), and MainWindow::openDialog().

{
    Q_D(QDialog);
    if (d->eventLoop) {
        qWarning("QDialog::exec: Recursive call detected");
        return -1;
    }

    bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
    setAttribute(Qt::WA_DeleteOnClose, false);

    bool wasShowModal = testAttribute(Qt::WA_ShowModal);
    setAttribute(Qt::WA_ShowModal, true);
    setResult(0);

//On Windows Mobile we create an empty menu to hide the current menu
#ifdef Q_OS_WINCE_WM
#ifndef QT_NO_MENUBAR
    QMenuBar *menuBar = 0;
    if (!findChild<QMenuBar *>())
        menuBar = new QMenuBar(this);
    if (qt_wince_is_smartphone()) {
        QAction *doneAction = new QAction(tr("Done"), this);
        menuBar->setDefaultAction(doneAction);
        connect(doneAction, SIGNAL(triggered()), this, SLOT(_q_doneAction()));
    }
#endif //QT_NO_MENUBAR
#endif //Q_OS_WINCE_WM

    show();

    QEventLoop eventLoop;
    d->eventLoop = &eventLoop;
    QPointer<QDialog> guard = this;
    (void) eventLoop.exec();
    if (guard.isNull())
        return QDialog::Rejected;
    d->eventLoop = 0;

    setAttribute(Qt::WA_ShowModal, wasShowModal);

    int res = result();
    if (deleteOnClose)
        delete this;
#ifdef Q_OS_WINCE_WM
#ifndef QT_NO_MENUBAR
    else if (menuBar)
        delete menuBar;
#endif //QT_NO_MENUBAR
#endif //Q_OS_WINCE_WM
    return res;
}


Generated by  Doxygen 1.6.0   Back to index