Qt logo

QDialog Class Reference


The QDialog class is the base class of dialog windows. More...

#include <qdialog.h>

Inherits QWidget.

Inherited by QFileDialog, QMessageBox, QPrintDialog and QTabDialog.

List of all member functions.

Public Members

Protected Members

Protected Slots


Detailed Description

The QDialog class is the base class of dialog windows.

A dialog window is a widget used to communicate with the user. It offers mechanisms such as default buttons.

The dialog window can either be modeless or modal. A modeless dialog is a normal window, while a modal window must be finished before the user can continue with other parts of the program. The third constructor argument must be set to TRUE to create a modal dialog, otherwise it will create a modeless dialog.

Example (your own modal dialog):

    class Modal : public QDialog {
        Q_OBJECT
    public:
        Modal( QWidget *parent, const char *name );
    };

    Modal::Modal( QWidget *parent, const char *name )
        : QDialog( parent, name, TRUE )
    {
        QPushButton *ok, *cancel;
        ok = new QPushButton( "Ok", this );
        ok->setGeometry( 10,10, 100,30 );
        connect( ok, SIGNAL(clicked()), SLOT(accept()) );
        cancel = new QPushButton( "Cancel", this );
        cancel->setGeometry( 10,60, 100,30 );
        connect( cancel, SIGNAL(clicked()), SLOT(reject()) );
    }

Note that the parent widget has a different meaning for modal dialogs than for other types of widgets. A dialog is placed on top of the parent widget. The dialog is centered on the screen if the parent widget is zero.

You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call >You would normally call