![]() |
Qt 6.x
The Qt SDK
|
#include "qquickdialogbuttonbox_p.h"
#include "qquickdialogbuttonbox_p_p.h"
#include "qquickabstractbutton_p.h"
#include "qquickbutton_p.h"
#include "qquickdialog_p_p.h"
#include <QtCore/qpointer.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformtheme.h>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
#include <QtQml/qqmlcomponent.h>
#include <algorithm>
#include "moc_qquickdialogbuttonbox_p.cpp"
Go to the source code of this file.
Functions | |
static QT_BEGIN_NAMESPACE QPlatformDialogHelper::ButtonLayout | platformButtonLayout () |
A button box used in dialogs. | |
static QRectF | alignedRect (Qt::LayoutDirection direction, Qt::Alignment alignment, const QSizeF &size, const QRectF &rectangle) |
|
static |
Definition at line 186 of file qquickdialogbuttonbox.cpp.
References Qt::AlignBottom, Qt::AlignHCenter, alignment, Qt::AlignRight, Qt::AlignVCenter, Qt::AlignVertical_Mask, direction, QSizeF::height(), QRectF::size(), QGuiApplicationPrivate::visualAlignment(), QSizeF::width(), QRectF::x(), and QRectF::y().
|
static |
A button box used in dialogs.
\qmltype DialogButtonBox \inherits Container
! \instantiates QQuickDialogButtonBox \inqmlmodule QtQuick.Controls
Dialogs and message boxes typically present buttons in an order that conforms to the interface guidelines for that platform. Invariably, different platforms have their dialog buttons in different orders. DialogButtonBox allows a developer to add buttons to it and will automatically use the appropriate order for the user's platform.
Most buttons for a dialog follow certain roles. Such roles include:
\list
There can also be alternate ways of dismissing the dialog which may cause destructive results.
Most dialogs have buttons that can almost be considered standard (e.g. \uicontrol OK and \uicontrol Cancel buttons). It is sometimes convenient to create these buttons in a standard way.
There are a couple ways of using DialogButtonBox. One way is to specify the standard buttons (e.g. \uicontrol OK, \uicontrol Cancel, \uicontrol Save) and let the button box setup the buttons.
Alternatively, buttons and their roles can be specified by hand:
You can also mix and match normal buttons and standard buttons.
When a button is clicked in the button box, the \l clicked() signal is emitted for the actual button that is pressed. In addition, the following signals are automatically emitted when a button with the respective role(s) is pressed:
\table \header
AcceptRole
, YesRole
ApplyRole
DiscardRole
HelpRole
RejectRole
, NoRole
ResetRole
\qmlsignal QtQuick.Controls::DialogButtonBox::accepted()
This signal is emitted when a button defined with the AcceptRole
or YesRole
is clicked.
\qmlsignal QtQuick.Controls::DialogButtonBox::rejected()
This signal is emitted when a button defined with the RejectRole
or NoRole
is clicked.
This signal is emitted when a button defined with the ApplyRole
is clicked.
This signal is emitted when a button defined with the ResetRole
is clicked.
This signal is emitted when a button defined with the DiscardRole
is clicked.
\qmlsignal QtQuick.Controls::DialogButtonBox::helpRequested()
This signal is emitted when a button defined with the HelpRole
is clicked.
\qmlsignal QtQuick.Controls::DialogButtonBox::clicked(AbstractButton button)
This signal is emitted when a button inside the button box is clicked.
Definition at line 162 of file qquickdialogbuttonbox.cpp.
References QPlatformTheme::DialogButtonBoxLayout, QGuiApplicationPrivate::platformTheme(), QPlatformTheme::themeHint(), and QVariant::value().
Referenced by QQuickDialogButtonBox::QQuickDialogButtonBox(), and QQuickDialogButtonBox::resetButtonLayout().