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()) {
258 p =
p->parentWidget();
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) {
527 if (
menu && !
d->menu) {
536 d->resetLayoutItemMargins();
548QMenu* QPushButton::menu()
const
559void QPushButton::showMenu()
565 d->_q_popupPressed();
576 QPoint menuPos = adjustedMenuPosition();
588QPoint QPushButtonPrivate::adjustedMenuPosition()
592 bool horizontal =
true;
593#if QT_CONFIG(toolbar)
605 int x = globalPos.
x();
606 int y = globalPos.
y();
609 if (globalPos.
y() +
rect.height() + menuSize.
height() <= availableGeometry.
bottom()) {
611 }
else if (globalPos.
y() - menuSize.
height() >= availableGeometry.
y()) {
619 }
else if (globalPos.
x() - menuSize.
width() >= availableGeometry.
x()) {
640 q->initStyleOption(&
opt);
650 d->resetLayoutItemMargins();
669 if (
d->defaultButton)
670 dialog->d_func()->setMainDefault(
this);
678 d->resetLayoutItemMargins();
688#include "moc_qpushbutton.cpp"
The QDialog class is the base class of dialog windows.
The QFocusEvent class contains event parameters for widget focus events.
\reentrant \inmodule QtGui
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=nullptr) const
Returns the size in pixels of text.
The QIcon class provides scalable icons in different modes and states.
The QKeyEvent class describes a key event.
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.
\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.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
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.
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]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent