9.3.  Dialogs

[ fromfile: dialogs.xml id: dialogs ]

Example 9.1. src/widgets/dialogs/modal/main.cpp

[ . . . . ]
#include <QtGui>
int main (int argc, char* argv[]) {
    QApplication app(argc, argv);
    QProgressDialog nonModal;
    nonModal.setWindowTitle("Non Modal Parent Dialog");
    nonModal.show();                    1
    nonModal.connect(&nonModal, SIGNAL(finished()), 
            &app, SLOT(quit()));        2    
[ . . . . ]
    QFileDialog fileDialog(&nonModal, "Modal File Child Dialog");
    // 2 modal dialogs. exec() takes over all user interactions until closed. 
    fileDialog.exec();                  3
    QMessageBox::question(0, QObject::tr("Modal parentless Dialog"),
            QObject::tr("can you interact with the other dialogs now?"), 
            QMessageBox::Yes | QMessageBox::No);
    return app.exec();                  4
}
[ . . . . ]

1

Returns immediately

2

Termination condition

3

Similar to entering an event loop, returns when window closes.

4

Quits when nonModal closes


Parents and Children

Input Dialogs

Figure 9.9.  Standard Dialogs

Standard Dialogs