Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QMotifDialog Class Reference

The QMotifDialog class provides the QDialog API for Motif dialogs. More...

This class is part of the Qt Motif Extension.

`#include <qmotifdialog.h>`

Inherits QDialog.

List of all member functions.

## Public Members

- enum DialogType { Prompt, Selection, Command, FileSelection, Template, Error, Information, Message, Question, Warning, Working }
- QMotifDialog ( DialogType dtype, Widget parent = NULL, ArgList args = NULL, Cardinal argcount = 0, const char * name = 0, bool modal = FALSE, WFlags flags = 0 )
- QMotifDialog ( Widget parent = NULL, ArgList args = NULL, Cardinal argcount = 0, const char * name = 0, bool modal = FALSE, WFlags flags = 0 )
- virtual ~QMotifDialog ()
- Widget shell () const
- Widget dialog () const

## Static Public Members

- void acceptCallback ( Widget, XtPointer client_data, XtPointer )
- void rejectCallback ( Widget, XtPointer client_data, XtPointer )

## Detailed Description

This class is defined in the Qt Motif Extension, which can be found in the `qt/extensions` directory. It is not included in the main Qt API.

The QMotifDialog class provides the QDialog API for Motif dialogs.

When migrating Motif applications to Qt, developers will want to rewrite their Motif dialogs using Qt, and switch to using Qt's modality semantics. QMotifDialog ensures that modal Motif dialogs continue to work properly when used in a Qt application.

For the purpose of the Motif extension, Motif has two types of dialogs: predefined dialogs and custom dialogs. The predefined Motif dialogs are:

- Prompt
- Selection
- Command
- FileSelection
- Template
- Error
- Information
- Message
- Question
- Warning
- Working

QMotifDialog provides a constructor for the predefined Motif dialog types, which creates a dialog shell and the dialog widget itself.

Example usage QMotifDialog to create a predefined Motif dialog:

        ...
        XmString message = XmStringCreateLocalized( "This is a Message dialog.",
                                                    XmSTRING_DEFAULT_CHARSET );
        Arg args[1];
        XtSetArg( args[0], XmNmessageString, message );

        // parent is an ApplicationShell created earlier in the application
        QMotifDialog dailog( QMotifDialog::Message, parent, args, 1,
                             "motif message dialog", TRUE );
        XtAddCallback( dialog.dialog(), XmNokCallback,
                       (XtCallbackProc) QMotifDialog::acceptCallback, &dialog );
        XtAddCallback( dialog.dialog(), XmNcancelCallback,
                       (XtCallbackProc) QMotifDialog::rejectCallback, &dialog );
        dialog.exec();

        XmStringFree( message );
        ...

QMotifDialog also provides a constructor for custom Motif dialogs, which only creates the dialog shell. The application programmer can create a custom dialog using the QMotifDialog shell as its parent.

QMotifDialogs can be used with either an Xt/Motif or a QWidget parent.

## Member Type Documentation

### QMotifDialog::DialogType

This enum lists the predefined Motif dialog types.

- `QMotifDialog::Prompt`
- `QMotifDialog::Selection`
- `QMotifDialog::Command`
- `QMotifDialog::FileSelection`
- `QMotifDialog::Template`
- `QMotifDialog::Error`
- `QMotifDialog::Information`
- `QMotifDialog::Message`
- `QMotifDialog::Question`
- `QMotifDialog::Warning`
- `QMotifDialog::Working`

## Member Function Documentation

### QMotifDialog::QMotifDialog ( DialogType dtype, Widget parent = NULL, ArgList args = NULL, Cardinal argcount = 0, const char * name = 0, bool modal = FALSE, WFlags flags = 0 )

Creates a predefined Motif dialog of type dtype with a Motif widget parent.

The arguments are passed in args, and the number of arguments in argcount. The name, modal and flags arguments are passed on to the QDialog constructor.

Creates a Shell widget which is a special subclass of XmDialogShell. This allows applications to use the QDialog API with existing Motif dialogs. It also means that applications can properly handle modality with the QMotif extension. You can access the Shell widget with the shell() member function.

Creates a dialog widget with the Shell widget as it's parent. The type of the dialog created is specified by the dtype argument. See the DialogType enum for a list of available dialog types. You can access the dialog widget with the dialog() member function.

Warning: When QMotifDialog is destroyed, the Shell widget and the dialog widget are destroyed. You should not destroy the dialog widget yourself.

### QMotifDialog::QMotifDialog ( Widget parent = NULL, ArgList args = NULL, Cardinal argcount = 0, const char * name = 0, bool modal = FALSE, WFlags flags = 0 )

Creates a QMotifDialog for use in a custom Motif dialog.

The dialog's parent is parent. The arguments are passed in args and the number of arguments in argcount. The name, modal and flags arguments are passed on to the QDialog constructor.

Creates a Shell widget which is a special subclass of XmDialogShell. This allows applications to use the QDialog API with existing Motif dialogs. It also means that applications can properly handle modality with the QMotif extension. You can access the Shell widget with the shell() member function.

A dialog widget is not created by this constructor. Instead, you should create the dialog widget as a child of this dialog. Once you do this, QMotifDialog will take ownership of your custom dialog, and you can access it with the dialog() member function.

Warning: When QMotifDialog is destroyed, the Shell widget and the dialog widget are destroyed. You should not destroy the dialog widget yourself.

### QMotifDialog::~QMotifDialog ()`[virtual]`

Destroys the QDialog, dialog widget and shell widget.

### void QMotifDialog::acceptCallback ( Widget, XtPointer client_data, XtPointer )`[static]`

Convenient Xt/Motif callback to accept the QMotifDialog.

The data is passed in client_data.

### Widget QMotifDialog::dialog () const

Returns the Motif widget embedded in this dialog.

Example: dialog/mainwindow.cpp.

### void QMotifDialog::rejectCallback ( Widget, XtPointer client_data, XtPointer )`[static]`

Convenient Xt/Motif callback to reject the QMotifDialog.

The data is passed in client_data.

### Widget QMotifDialog::shell () const

Returns the Shell widget embedded in this dialog.

Example: dialog/mainwindow.cpp.

This file is part of the Qt toolkit. Copyright © 1995-2002 Trolltech. All Rights Reserved.