Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwidgetplatformmessagedialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7#include <QtWidgets/qmessagebox.h>
8#include <QtWidgets/qabstractbutton.h>
9
11
13 : m_dialog(new QMessageBox)
14{
16
19 connect(m_dialog.data(), &QMessageBox::buttonClicked, this, [this](QAbstractButton *button) {
20 QMessageBox::ButtonRole role = m_dialog->buttonRole(button);
21 QMessageBox::StandardButton standardButton = m_dialog->standardButton(button);
22 emit clicked(static_cast<StandardButton>(standardButton), static_cast<ButtonRole>(role));
23 });
24}
25
30{
31 m_dialog->exec();
32}
33
35{
36 QSharedPointer<QMessageDialogOptions> options = QPlatformMessageDialogHelper::options();
38 m_dialog->setIcon(static_cast<QMessageBox::Icon>(options->standardIcon()));
39 m_dialog->setText(options->text());
41#if QT_CONFIG(textedit)
42 m_dialog->setDetailedText(options->detailedText());
43#endif
44 m_dialog->setStandardButtons(static_cast<QMessageBox::StandardButtons>(int(options->standardButtons())));
45
46 return QWidgetPlatformDialog::show(m_dialog.data(), flags, modality, parent);
47}
48
50{
51 m_dialog->hide();
52}
53
55
56#include "moc_qwidgetplatformmessagedialog_p.cpp"
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void rejected()
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:543
void accepted()
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition qmessagebox.h:22
void setStandardButtons(StandardButtons buttons)
void setWindowTitle(const QString &title)
void buttonClicked(QAbstractButton *button)
This signal is emitted whenever a button is clicked inside the QMessageBox.
void setIcon(Icon)
void setInformativeText(const QString &text)
Icon
This enum has the following values:
Definition qmessagebox.h:43
void setText(const QString &text)
StandardIcon standardIcon() const
QPlatformDialogHelper::StandardButtons standardButtons() const
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
void setParent(QObject *parent)
Makes the object a child of parent.
Definition qobject.cpp:2195
virtual void exec()=0
virtual void hide()=0
virtual bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)=0
const QSharedPointer< QMessageDialogOptions > & options() const
T * data() const noexcept
Returns the value of the pointer referenced by this object.
static bool show(QDialog *dialog, Qt::WindowFlags flags, Qt::WindowModality modality, QWindow *parent)
QWidgetPlatformMessageDialog(QObject *parent=nullptr)
void hide()
Hides the widget.
Definition qwidget.cpp:8135
\inmodule QtGui
Definition qwindow.h:63
QPushButton * button
[2]
Combined button and popup list for selecting options.
WindowModality
GLbitfield flags