ZDialog

  • _images/dialog-windowtitle.tpi.8ebecd4930.png

    Dialog with title “WindowTitle”

  • _images/dialog-options.tpi.f2d23a2f64.png

    with system menu

ZDialog is a widget derived from Tui::ZWindow specialized for dialogs.

It adds the concept of rejecting the dialog and of a default widget. It also uses the palette class dialog which yields a visually distinct appearance in the default palettes.

Default widget

In dialogs a widget can be the default widget. This means that if the focused widget does not itself use the Enter key the default widget will handle the Enter key.

An example of a widget that can act as a default widget is Tui::ZButton.

For details on the exact rules see ZBasicDefaultWindowManager.

Example

Tui::ZDialog dialog(root);
dialog.setGeometry({1, 1, 18, 4});
dialog.setOptions({Tui::ZWindow::MoveOption |
                   Tui::ZWindow::ResizeOption |
                   Tui::ZWindow::CloseOption |
                   Tui::ZWindow::AutomaticOption |
                   Tui::ZWindow::ContainerOptions });

Keyboard Usage

Key

State

Result

Esc

normal

Reject the dialog.

Enter

normal

Trigger the default widget, if set and active.

For additional related keys see Tui::ZWindow and Tui::ZRoot.

Behavior

Most behavior is inherited from ZWindow.

In addition ZDialog has a palette class of (window, dialog) and defaults to stacking layer 1000.

The dialog will automatically resize itself and enable auto placement to center on certain conditions. It does this only once per instance. It checks after creation in the next main loop iteration and when the dialog is shown, if the dialog is visible and has a parent widget the automatic size and positioning code triggers.

If the dialog already has a geometry nothing further is done and the auto sizing will not happen for the instance, otherwise the dialog will be resized according to the value of QSize Tui::ZWidget::effectiveSizeHint() const and automatic placement in the center of the parent widget is enabled.

The dialog implements the ZDefaultWidgetManager facet using ZBasicDefaultWindowManager or a derived class.

ZDialog

class Tui::ZDialog : public Tui::ZWindow

A dialog window class.

Signals

void rejected()

This dialog is emitted when the dialog is rejected either using the reject() function or by pressing Esc.

Slots

void reject()

Hides the dialog and triggers emission of the rejected() signal.