7#include <private/qdialog_p.h>
23#if QT_CONFIG(dialogbuttonbox)
27#if QT_CONFIG(accessibility)
33#include "private/qmenu_p.h"
35#include "private/qpushbutton_p.h"
257 while (
p && !
p->isWindow()) {
289 if (
d->defaultButton)
291 if (
d->down ||
d->menuOpen)
295 if (!
d->flat && !
d->down)
320 return (
d->dialogParent() !=
nullptr );
321 return d->autoDefault;
327 if (
d->defaultButton ==
enable)
331 if (
d->defaultButton) {
332 if (
QDialog *dlg =
d->dialogParent())
333 dlg->d_func()->setMainDefault(
this);
337#if QT_CONFIG(accessibility)
339 s.defaultButton =
true;
340 QAccessibleStateChangeEvent
event(
this,
s);
341 QAccessible::updateAccessibility(&
event);
348 return d->defaultButton;
357 if (
d->sizeHint.isValid() &&
d->lastAutoDefault ==
autoDefault())
368#if !defined(QT_NO_ICON) && QT_CONFIG(dialogbuttonbox)
369 bool showButtonBoxIcons = qobject_cast<QDialogButtonBox*>(
parentWidget())
372 if (!
icon().isNull() || showButtonBoxIcons) {
380 bool empty =
s.isEmpty();
442 d->defaultButton =
true;
446 dlg->d_func()->setDefault(
this);
462 dlg->d_func()->setDefault(
nullptr);
464 d->defaultButton =
false;
470 if (
d->menu &&
d->menu->isVisible())
487 if (hit !=
d->hovering) {
504 return bevel.contains(
pos);
527 if (
menu && !
d->menu) {
537 d->resetLayoutItemMargins();
549QMenu* QPushButton::menu()
const
560void QPushButton::showMenu()
577 QPoint menuPos = adjustedMenuPosition();
589QPoint QPushButtonPrivate::adjustedMenuPosition()
593 bool horizontal =
true;
594#if QT_CONFIG(toolbar)
606 int x = globalPos.
x();
607 int y = globalPos.
y();
610 if (globalPos.
y() +
rect.height() + menuSize.height() <= availableGeometry.
bottom()) {
612 }
else if (globalPos.
y() - menuSize.height() >= availableGeometry.
y()) {
613 y -= menuSize.height();
616 x +=
rect.width() - menuSize.width();
620 }
else if (globalPos.
x() - menuSize.width() >= availableGeometry.
x()) {
621 x -= menuSize.width();
641 q->initStyleOption(&
opt);
651 d->resetLayoutItemMargins();
670 if (
d->defaultButton)
671 dialog->d_func()->setMainDefault(
this);
679 d->resetLayoutItemMargins();
689#include "moc_qpushbutton.cpp"
The QDialog class is the base class of dialog windows.
Type type() const
Returns the event type.
The QFocusEvent class contains event parameters for widget focus events.
Qt::FocusReason reason() const
Returns the reason for this focus event.
\reentrant \inmodule QtGui
The QIcon class provides scalable icons in different modes and states.
The QKeyEvent class describes a key event.
int key() const
Returns the code of the key that was pressed or released.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QPaintEvent class contains event parameters for paint events.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr void setSize(const QSize &s) noexcept
Sets the size of the rectangle to the given size.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_DialogButtonBox_ButtonsHaveIcons
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const =0
Returns the sub-area for the given element as described in the provided style option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
@ SE_PushButtonLayoutItem
Combined button and popup list for selecting options.
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLfloat GLfloat GLfloat GLfloat h
GLdouble GLdouble GLdouble GLdouble q
#define QStringLiteral(str)
QFileDialog dialog(this)
[1]