QInstaller::MessageBoxHandler Class

class QInstaller::MessageBoxHandler

The MessageBoxHandler class provides a modal dialog for informing the user or asking the user a question and receiving an answer. More...

Header: #include <MessageBoxHandler>
Inherits: QObject

Public Types

enum DefaultAction { AskUser, Accept, Reject, Default }
enum MessageType { criticalType, informationType, questionType, warningType }

Public Functions

int critical(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)
int information(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)
int question(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Yes | QMessageBox::No, int button = QMessageBox::NoButton)
void setAutomaticAnswer(const QString &identifier, QMessageBox::StandardButton answer)
void setDefaultAction(QInstaller::MessageBoxHandler::DefaultAction defaultAction)
int warning(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)

Static Public Members

QMessageBox::StandardButton critical(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)
QWidget *currentBestSuitParent()
QMessageBox::StandardButton information(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)
QInstaller::MessageBoxHandler *instance()
QList<QMessageBox::Button> orderedButtons()
QMessageBox::StandardButton question(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No, QMessageBox::StandardButton button = QMessageBox::NoButton)
QMessageBox::StandardButton warning(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)

Detailed Description

var result = QMessageBox.question("quit.question", "Installer", "Do you want to quit the installer?",
                                  QMessageBox.Yes | QMessageBox.No);
if (result == QMessageBox.Yes) {
   // ...
}

Buttons in Message Boxes

QMessageBox defines a list of common buttons:

Member Type Documentation

enum MessageBoxHandler::DefaultAction

This enum value holds the default action for the message box handler:

ConstantValueDescription
QInstaller::MessageBoxHandler::AskUser0Ask the end user for confirmation.
QInstaller::MessageBoxHandler::Accept1Accept the message box.
QInstaller::MessageBoxHandler::Reject2Reject the message box.
QInstaller::MessageBoxHandler::Default3Uses default answer set for message box.

enum MessageBoxHandler::MessageType

This enum value holds the severity level of the message displayed in the message box:

ConstantValueDescription
QInstaller::MessageBoxHandler::criticalType0Reports critical errors.
QInstaller::MessageBoxHandler::informationType1Reports information about normal operations.
QInstaller::MessageBoxHandler::questionType2Asks a question during normal operations.
QInstaller::MessageBoxHandler::warningType3Reports non-critical errors.

Member Function Documentation

[invokable] int MessageBoxHandler::critical(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)

Opens a critical message box with the identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static] QMessageBox::StandardButton MessageBoxHandler::critical(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)

Opens a critical message box with the parent parent, identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

[static] QWidget *MessageBoxHandler::currentBestSuitParent()

Returns the widget or window that is most suitable to become the parent of the message box. Returns 0 if an application cannot be found.

[invokable] int MessageBoxHandler::information(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)

Opens an information message box with the identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static] QMessageBox::StandardButton MessageBoxHandler::information(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)

Opens an information message box with the parent parent, identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

[static] QInstaller::MessageBoxHandler *MessageBoxHandler::instance()

Returns a message box handler instance.

[static] QList<QMessageBox::Button> MessageBoxHandler::orderedButtons()

Returns an ordered list of buttons to display in the message box.

[invokable] int MessageBoxHandler::question(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Yes | QMessageBox::No, int button = QMessageBox::NoButton)

Opens a question message box with the identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static] QMessageBox::StandardButton MessageBoxHandler::question(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No, QMessageBox::StandardButton button = QMessageBox::NoButton)

Opens a question message box with the parent parent, identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

void MessageBoxHandler::setAutomaticAnswer(const QString &identifier, QMessageBox::StandardButton answer)

Sets the button that is used as the default button and that is automatically invoked if a message box is shown in automatic mode. The string identifier is used to identify the message box that the default button answer is associated to.

void MessageBoxHandler::setDefaultAction(QInstaller::MessageBoxHandler::DefaultAction defaultAction)

Sets the default action for the message box to defaultAction.

[invokable] int MessageBoxHandler::warning(const QString &identifier, const QString &title, const QString &text, int buttons = QMessageBox::Ok, int button = QMessageBox::NoButton)

Opens a warning message box with the identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

[static] QMessageBox::StandardButton MessageBoxHandler::warning(QWidget *parent, const QString &identifier, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton button = QMessageBox::NoButton)

Opens a warning message box with the parent parent, identifier identifier, title title, and text text.

The standard buttons specified by buttons are added to the message box. button specifies the button that is used when Enter is pressed. button must refer to a button that is specified in buttons. If button is QMessageBox::NoButton, a suitable default is chosen automatically.

Returns the identity of the standard button that was clicked. However, if Esc was pressed, returns the escape button.

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The Qt Company, Qt and their respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.