Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qwidget.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QWIDGET_H
0005 #define QWIDGET_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtGui/qwindowdefs.h>
0009 #include <QtCore/qobject.h>
0010 #include <QtCore/qmargins.h>
0011 #if QT_CONFIG(action)
0012 #include <QtGui/qaction.h>
0013 #endif
0014 #include <QtGui/qpaintdevice.h>
0015 #include <QtGui/qpalette.h>
0016 #include <QtGui/qfont.h>
0017 #include <QtGui/qfontmetrics.h>
0018 #include <QtGui/qfontinfo.h>
0019 #include <QtWidgets/qsizepolicy.h>
0020 #include <QtGui/qregion.h>
0021 #include <QtGui/qbrush.h>
0022 #include <QtGui/qcursor.h>
0023 #if QT_CONFIG(shortcut)
0024 #  include <QtGui/qkeysequence.h>
0025 #endif
0026 
0027 #ifdef QT_INCLUDE_COMPAT
0028 #include <QtGui/qevent.h>
0029 #endif
0030 
0031 QT_BEGIN_NAMESPACE
0032 
0033 
0034 class QLayout;
0035 class QStyle;
0036 class QAction;
0037 class QVariant;
0038 class QWindow;
0039 class QActionEvent;
0040 class QMouseEvent;
0041 class QWheelEvent;
0042 class QHoverEvent;
0043 class QKeyEvent;
0044 class QEnterEvent;
0045 class QFocusEvent;
0046 class QPaintEvent;
0047 class QMoveEvent;
0048 class QResizeEvent;
0049 class QCloseEvent;
0050 class QContextMenuEvent;
0051 class QInputMethodEvent;
0052 class QTabletEvent;
0053 class QDragEnterEvent;
0054 class QDragMoveEvent;
0055 class QDragLeaveEvent;
0056 class QDropEvent;
0057 class QScreen;
0058 class QShowEvent;
0059 class QHideEvent;
0060 class QIcon;
0061 class QBackingStore;
0062 class QPlatformWindow;
0063 class QLocale;
0064 class QGraphicsProxyWidget;
0065 class QGraphicsEffect;
0066 class QRasterWindowSurface;
0067 class QUnifiedToolbarSurface;
0068 class QPixmap;
0069 #ifndef QT_NO_DEBUG_STREAM
0070 class QDebug;
0071 #endif
0072 
0073 class QWidgetData
0074 {
0075 public:
0076     WId winid;
0077     uint widget_attributes;
0078     Qt::WindowFlags window_flags;
0079     uint window_state : 4;
0080     uint focus_policy : 4;
0081     uint sizehint_forced :1;
0082     uint is_closing :1;
0083     uint in_show : 1;
0084     uint in_set_window_state : 1;
0085     mutable uint fstrut_dirty : 1;
0086     uint context_menu_policy : 3;
0087     uint window_modality : 2;
0088     uint in_destructor : 1;
0089     uint unused : 13;
0090     QRect crect;
0091     mutable QPalette pal;
0092     QFont fnt;
0093     QRect wrect;
0094 };
0095 
0096 class QWidgetPrivate;
0097 
0098 class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
0099 {
0100     Q_OBJECT
0101     Q_DECLARE_PRIVATE(QWidget)
0102 
0103     Q_PROPERTY(bool modal READ isModal)
0104     Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
0105     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
0106     Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
0107     Q_PROPERTY(QRect frameGeometry READ frameGeometry)
0108     Q_PROPERTY(QRect normalGeometry READ normalGeometry)
0109     Q_PROPERTY(int x READ x)
0110     Q_PROPERTY(int y READ y)
0111     Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
0112     Q_PROPERTY(QSize frameSize READ frameSize)
0113     Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
0114     Q_PROPERTY(int width READ width)
0115     Q_PROPERTY(int height READ height)
0116     Q_PROPERTY(QRect rect READ rect)
0117     Q_PROPERTY(QRect childrenRect READ childrenRect)
0118     Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
0119     Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
0120     Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
0121     Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
0122     Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false
0123                DESIGNABLE false)
0124     Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false
0125                DESIGNABLE false)
0126     Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false
0127                DESIGNABLE false)
0128     Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false
0129                DESIGNABLE false)
0130     Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
0131     Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
0132     Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
0133     Q_PROPERTY(QFont font READ font WRITE setFont)
0134 #ifndef QT_NO_CURSOR
0135     Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
0136 #endif
0137     Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
0138     Q_PROPERTY(bool tabletTracking READ hasTabletTracking WRITE setTabletTracking)
0139     Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
0140     Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
0141     Q_PROPERTY(bool focus READ hasFocus)
0142     Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
0143     Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
0144     Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
0145     Q_PROPERTY(bool minimized READ isMinimized)
0146     Q_PROPERTY(bool maximized READ isMaximized)
0147     Q_PROPERTY(bool fullScreen READ isFullScreen)
0148     Q_PROPERTY(QSize sizeHint READ sizeHint)
0149     Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
0150     Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
0151     Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged)
0152     Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged)
0153     Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged) // deprecated
0154     Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity)
0155     Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified)
0156 #if QT_CONFIG(tooltip)
0157     Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
0158     Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)
0159 #endif
0160 #if QT_CONFIG(statustip)
0161     Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
0162 #endif
0163 #if QT_CONFIG(whatsthis)
0164     Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
0165 #endif
0166 #if QT_CONFIG(accessibility)
0167     Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
0168     Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
0169 #endif
0170     Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
0171     QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
0172     Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
0173 #ifndef QT_NO_STYLE_STYLESHEET
0174     Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
0175 #endif
0176     Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
0177     Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath)
0178     Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
0179 
0180 #if QT_CONFIG(action)
0181 #if 0
0182     // ### TODO: make this work (requires SFINAE-friendly connect())
0183     template <typename...Args>
0184     using compatible_action_slot_args = std::void_t<
0185         decltype(QObject::connect(std::declval<QAction*>(), &QAction::triggered,
0186                                   std::declval<Args>()...))
0187     >;
0188 #else
0189     // good-enough compromise for now
0190     template <typename...Args>
0191     using compatible_action_slot_args = std::enable_if_t<std::conjunction_v<
0192 #if QT_CONFIG(shortcut)
0193             std::disjunction<
0194                 std::is_same<Args, Qt::ConnectionType>,
0195                 std::negation<std::is_convertible<Args, QKeySequence>>
0196             >...,
0197 #endif
0198             std::negation<std::is_convertible<Args, QIcon>>...,
0199             std::negation<std::is_convertible<Args, const char*>>...,
0200             std::negation<std::is_convertible<Args, QString>>...
0201         >>;
0202 #endif
0203 #endif // QT_CONFIG(action)
0204 
0205 public:
0206     enum RenderFlag {
0207         DrawWindowBackground = 0x1,
0208         DrawChildren = 0x2,
0209         IgnoreMask = 0x4
0210     };
0211     Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
0212 
0213     explicit QWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
0214     ~QWidget();
0215 
0216     int devType() const override;
0217 
0218     WId winId() const;
0219     void createWinId(); // internal, going away
0220     inline WId internalWinId() const { return data->winid; }
0221     WId effectiveWinId() const;
0222 
0223     // GUI style setting
0224     QStyle *style() const;
0225     void setStyle(QStyle *);
0226     // Widget types and states
0227 
0228 #if QT_DEPRECATED_SINCE(6, 1)
0229     QT_DEPRECATED_VERSION_X_6_1("Use isWindow()")
0230     bool isTopLevel() const;
0231 #endif
0232     bool isWindow() const;
0233 
0234     bool isModal() const;
0235     Qt::WindowModality windowModality() const;
0236     void setWindowModality(Qt::WindowModality windowModality);
0237 
0238     bool isEnabled() const;
0239     bool isEnabledTo(const QWidget *) const;
0240 
0241 public Q_SLOTS:
0242     void setEnabled(bool);
0243     void setDisabled(bool);
0244     void setWindowModified(bool);
0245 
0246     // Widget coordinates
0247 
0248 public:
0249     QRect frameGeometry() const;
0250     const QRect &geometry() const;
0251     QRect normalGeometry() const;
0252 
0253     int x() const;
0254     int y() const;
0255     QPoint pos() const;
0256     QSize frameSize() const;
0257     QSize size() const;
0258     inline int width() const;
0259     inline int height() const;
0260     inline QRect rect() const;
0261     QRect childrenRect() const;
0262     QRegion childrenRegion() const;
0263 
0264     QSize minimumSize() const;
0265     QSize maximumSize() const;
0266     int minimumWidth() const;
0267     int minimumHeight() const;
0268     int maximumWidth() const;
0269     int maximumHeight() const;
0270     void setMinimumSize(const QSize &);
0271     void setMinimumSize(int minw, int minh);
0272     void setMaximumSize(const QSize &);
0273     void setMaximumSize(int maxw, int maxh);
0274     void setMinimumWidth(int minw);
0275     void setMinimumHeight(int minh);
0276     void setMaximumWidth(int maxw);
0277     void setMaximumHeight(int maxh);
0278 
0279 #ifdef Q_QDOC
0280     void setupUi(QWidget *widget);
0281 #endif
0282 
0283     QSize sizeIncrement() const;
0284     void setSizeIncrement(const QSize &);
0285     void setSizeIncrement(int w, int h);
0286     QSize baseSize() const;
0287     void setBaseSize(const QSize &);
0288     void setBaseSize(int basew, int baseh);
0289 
0290     void setFixedSize(const QSize &);
0291     void setFixedSize(int w, int h);
0292     void setFixedWidth(int w);
0293     void setFixedHeight(int h);
0294 
0295     // Widget coordinate mapping
0296 
0297     QPointF mapToGlobal(const QPointF &) const;
0298     QPoint mapToGlobal(const QPoint &) const;
0299     QPointF mapFromGlobal(const QPointF &) const;
0300     QPoint mapFromGlobal(const QPoint &) const;
0301     QPointF mapToParent(const QPointF &) const;
0302     QPoint mapToParent(const QPoint &) const;
0303     QPointF mapFromParent(const QPointF &) const;
0304     QPoint mapFromParent(const QPoint &) const;
0305     QPointF mapTo(const QWidget *, const QPointF &) const;
0306     QPoint mapTo(const QWidget *, const QPoint &) const;
0307     QPointF mapFrom(const QWidget *, const QPointF &) const;
0308     QPoint mapFrom(const QWidget *, const QPoint &) const;
0309 
0310     QWidget *window() const;
0311     QWidget *nativeParentWidget() const;
0312     inline QWidget *topLevelWidget() const { return window(); }
0313 
0314     // Widget appearance functions
0315     const QPalette &palette() const;
0316     void setPalette(const QPalette &);
0317 
0318     void setBackgroundRole(QPalette::ColorRole);
0319     QPalette::ColorRole backgroundRole() const;
0320 
0321     void setForegroundRole(QPalette::ColorRole);
0322     QPalette::ColorRole foregroundRole() const;
0323 
0324     const QFont &font() const;
0325     void setFont(const QFont &);
0326     QFontMetrics fontMetrics() const;
0327     QFontInfo fontInfo() const;
0328 
0329 #ifndef QT_NO_CURSOR
0330     QCursor cursor() const;
0331     void setCursor(const QCursor &);
0332     void unsetCursor();
0333 #endif
0334 
0335     void setMouseTracking(bool enable);
0336     bool hasMouseTracking() const;
0337     bool underMouse() const;
0338 
0339     void setTabletTracking(bool enable);
0340     bool hasTabletTracking() const;
0341 
0342     void setMask(const QBitmap &);
0343     void setMask(const QRegion &);
0344     QRegion mask() const;
0345     void clearMask();
0346 
0347     void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(),
0348                 const QRegion &sourceRegion = QRegion(),
0349                 RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
0350 
0351     void render(QPainter *painter, const QPoint &targetOffset = QPoint(),
0352                 const QRegion &sourceRegion = QRegion(),
0353                 RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
0354 
0355     Q_INVOKABLE QPixmap grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1)));
0356 
0357 #if QT_CONFIG(graphicseffect)
0358     QGraphicsEffect *graphicsEffect() const;
0359     void setGraphicsEffect(QGraphicsEffect *effect);
0360 #endif // QT_CONFIG(graphicseffect)
0361 
0362 #ifndef QT_NO_GESTURES
0363     void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
0364     void ungrabGesture(Qt::GestureType type);
0365 #endif
0366 
0367 public Q_SLOTS:
0368     void setWindowTitle(const QString &);
0369 #ifndef QT_NO_STYLE_STYLESHEET
0370     void setStyleSheet(const QString& styleSheet);
0371 #endif
0372 public:
0373 #ifndef QT_NO_STYLE_STYLESHEET
0374     QString styleSheet() const;
0375 #endif
0376     QString windowTitle() const;
0377     void setWindowIcon(const QIcon &icon);
0378     QIcon windowIcon() const;
0379     void setWindowIconText(const QString &);
0380     QString windowIconText() const;
0381     void setWindowRole(const QString &);
0382     QString windowRole() const;
0383     void setWindowFilePath(const QString &filePath);
0384     QString windowFilePath() const;
0385 
0386     void setWindowOpacity(qreal level);
0387     qreal windowOpacity() const;
0388 
0389     bool isWindowModified() const;
0390 #if QT_CONFIG(tooltip)
0391     void setToolTip(const QString &);
0392     QString toolTip() const;
0393     void setToolTipDuration(int msec);
0394     int toolTipDuration() const;
0395 #endif
0396 #if QT_CONFIG(statustip)
0397     void setStatusTip(const QString &);
0398     QString statusTip() const;
0399 #endif
0400 #if QT_CONFIG(whatsthis)
0401     void setWhatsThis(const QString &);
0402     QString whatsThis() const;
0403 #endif
0404 #if QT_CONFIG(accessibility)
0405     QString accessibleName() const;
0406     void setAccessibleName(const QString &name);
0407     QString accessibleDescription() const;
0408     void setAccessibleDescription(const QString &description);
0409 #endif
0410 
0411     void setLayoutDirection(Qt::LayoutDirection direction);
0412     Qt::LayoutDirection layoutDirection() const;
0413     void unsetLayoutDirection();
0414 
0415     void setLocale(const QLocale &locale);
0416     QLocale locale() const;
0417     void unsetLocale();
0418 
0419     inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
0420     inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
0421 
0422 public Q_SLOTS:
0423     inline void setFocus() { setFocus(Qt::OtherFocusReason); }
0424 
0425 public:
0426     bool isActiveWindow() const;
0427     void activateWindow();
0428     void clearFocus();
0429 
0430     void setFocus(Qt::FocusReason reason);
0431     Qt::FocusPolicy focusPolicy() const;
0432     void setFocusPolicy(Qt::FocusPolicy policy);
0433     bool hasFocus() const;
0434     static void setTabOrder(QWidget *, QWidget *);
0435     static void setTabOrder(std::initializer_list<QWidget *> widgets);
0436     void setFocusProxy(QWidget *);
0437     QWidget *focusProxy() const;
0438     Qt::ContextMenuPolicy contextMenuPolicy() const;
0439     void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
0440 
0441     // Grab functions
0442     void grabMouse();
0443 #ifndef QT_NO_CURSOR
0444     void grabMouse(const QCursor &);
0445 #endif
0446     void releaseMouse();
0447     void grabKeyboard();
0448     void releaseKeyboard();
0449 #ifndef QT_NO_SHORTCUT
0450     int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
0451     void releaseShortcut(int id);
0452     void setShortcutEnabled(int id, bool enable = true);
0453     void setShortcutAutoRepeat(int id, bool enable = true);
0454 #endif
0455     static QWidget *mouseGrabber();
0456     static QWidget *keyboardGrabber();
0457 
0458     // Update/refresh functions
0459     inline bool updatesEnabled() const;
0460     void setUpdatesEnabled(bool enable);
0461 
0462 #if QT_CONFIG(graphicsview)
0463     QGraphicsProxyWidget *graphicsProxyWidget() const;
0464 #endif
0465 
0466 public Q_SLOTS:
0467     void update();
0468     void repaint();
0469 
0470 public:
0471     inline void update(int x, int y, int w, int h);
0472     void update(const QRect&);
0473     void update(const QRegion&);
0474 
0475     void repaint(int x, int y, int w, int h);
0476     void repaint(const QRect &);
0477     void repaint(const QRegion &);
0478 
0479 public Q_SLOTS:
0480     // Widget management functions
0481 
0482     virtual void setVisible(bool visible);
0483     void setHidden(bool hidden);
0484     void show();
0485     void hide();
0486 
0487     void showMinimized();
0488     void showMaximized();
0489     void showFullScreen();
0490     void showNormal();
0491 
0492     bool close();
0493     void raise();
0494     void lower();
0495 
0496 public:
0497     void stackUnder(QWidget*);
0498     void move(int x, int y);
0499     void move(const QPoint &);
0500     void resize(int w, int h);
0501     void resize(const QSize &);
0502     inline void setGeometry(int x, int y, int w, int h);
0503     void setGeometry(const QRect &);
0504     QByteArray saveGeometry() const;
0505     bool restoreGeometry(const QByteArray &geometry);
0506     void adjustSize();
0507     bool isVisible() const;
0508     bool isVisibleTo(const QWidget *) const;
0509     inline bool isHidden() const;
0510 
0511     bool isMinimized() const;
0512     bool isMaximized() const;
0513     bool isFullScreen() const;
0514 
0515     Qt::WindowStates windowState() const;
0516     void setWindowState(Qt::WindowStates state);
0517     void overrideWindowState(Qt::WindowStates state);
0518 
0519     virtual QSize sizeHint() const;
0520     virtual QSize minimumSizeHint() const;
0521 
0522     QSizePolicy sizePolicy() const;
0523     void setSizePolicy(QSizePolicy);
0524     inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
0525     virtual int heightForWidth(int) const;
0526     virtual bool hasHeightForWidth() const;
0527 
0528     QRegion visibleRegion() const;
0529 
0530     void setContentsMargins(int left, int top, int right, int bottom);
0531     void setContentsMargins(const QMargins &margins);
0532     QMargins contentsMargins() const;
0533 
0534     QRect contentsRect() const;
0535 
0536 public:
0537     QLayout *layout() const;
0538     void setLayout(QLayout *);
0539     void updateGeometry();
0540 
0541     void setParent(QWidget *parent);
0542     void setParent(QWidget *parent, Qt::WindowFlags f);
0543 
0544     void scroll(int dx, int dy);
0545     void scroll(int dx, int dy, const QRect&);
0546 
0547     // Misc. functions
0548 
0549     QWidget *focusWidget() const;
0550     QWidget *nextInFocusChain() const;
0551     QWidget *previousInFocusChain() const;
0552 
0553     // drag and drop
0554     bool acceptDrops() const;
0555     void setAcceptDrops(bool on);
0556 
0557 #ifndef QT_NO_ACTION
0558     //actions
0559     void addAction(QAction *action);
0560     void addActions(const QList<QAction*> &actions);
0561     void insertActions(QAction *before, const QList<QAction*> &actions);
0562     void insertAction(QAction *before, QAction *action);
0563     void removeAction(QAction *action);
0564     QList<QAction*> actions() const;
0565 
0566     // convenience action factories
0567     QAction *addAction(const QString &text);
0568     QAction *addAction(const QIcon &icon, const QString &text);
0569     QAction *addAction(const QString &text, const QObject *receiver,
0570                        const char *member, Qt::ConnectionType type = Qt::AutoConnection);
0571     QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver,
0572                        const char *member, Qt::ConnectionType type = Qt::AutoConnection);
0573     template <typename...Args, typename = compatible_action_slot_args<Args...>>
0574     QAction *addAction(const QString &text, Args&&...args)
0575     {
0576         QAction *result = addAction(text);
0577         connect(result, &QAction::triggered, std::forward<Args>(args)...);
0578         return result;
0579     }
0580     template <typename...Args, typename = compatible_action_slot_args<Args...>>
0581     QAction *addAction(const QIcon &icon, const QString &text, Args&&...args)
0582     {
0583         QAction *result = addAction(icon, text);
0584         connect(result, &QAction::triggered, std::forward<Args>(args)...);
0585         return result;
0586     }
0587 
0588 #if QT_CONFIG(shortcut)
0589     QAction *addAction(const QString &text, const QKeySequence &shortcut);
0590     QAction *addAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut);
0591     QAction *addAction(const QString &text, const QKeySequence &shortcut,
0592                        const QObject *receiver, const char *member,
0593                        Qt::ConnectionType type = Qt::AutoConnection);
0594     QAction *addAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut,
0595                        const QObject *receiver, const char *member,
0596                        Qt::ConnectionType type = Qt::AutoConnection);
0597 
0598     template <typename...Args, typename = compatible_action_slot_args<Args...>>
0599     QAction *addAction(const QString &text, const QKeySequence &shortcut, Args&&...args)
0600     {
0601         QAction *result = addAction(text, shortcut);
0602         connect(result, &QAction::triggered, std::forward<Args>(args)...);
0603         return result;
0604     }
0605     template <typename...Args, typename = compatible_action_slot_args<Args...>>
0606     QAction *addAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut, Args&&...args)
0607     {
0608         QAction *result = addAction(icon, text, shortcut);
0609         connect(result, &QAction::triggered, std::forward<Args>(args)...);
0610         return result;
0611     }
0612 #endif // QT_CONFIG(shortcut)
0613 #endif // QT_NO_ACTION
0614 
0615     QWidget *parentWidget() const;
0616 
0617     void setWindowFlags(Qt::WindowFlags type);
0618     inline Qt::WindowFlags windowFlags() const;
0619     void setWindowFlag(Qt::WindowType, bool on = true);
0620     void overrideWindowFlags(Qt::WindowFlags type);
0621 
0622     inline Qt::WindowType windowType() const;
0623 
0624     static QWidget *find(WId);
0625     inline QWidget *childAt(int x, int y) const;
0626     QWidget *childAt(const QPoint &p) const;
0627 
0628     void setAttribute(Qt::WidgetAttribute, bool on = true);
0629     inline bool testAttribute(Qt::WidgetAttribute) const;
0630 
0631     QPaintEngine *paintEngine() const override;
0632 
0633     void ensurePolished() const;
0634 
0635     bool isAncestorOf(const QWidget *child) const;
0636 
0637 #ifdef QT_KEYPAD_NAVIGATION
0638     bool hasEditFocus() const;
0639     void setEditFocus(bool on);
0640 #endif
0641 
0642     bool autoFillBackground() const;
0643     void setAutoFillBackground(bool enabled);
0644 
0645     QBackingStore *backingStore() const;
0646 
0647     QWindow *windowHandle() const;
0648     QScreen *screen() const;
0649     void setScreen(QScreen *);
0650 
0651     static QWidget *createWindowContainer(QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags());
0652 
0653 Q_SIGNALS:
0654     void windowTitleChanged(const QString &title);
0655     void windowIconChanged(const QIcon &icon);
0656     void windowIconTextChanged(const QString &iconText);
0657     void customContextMenuRequested(const QPoint &pos);
0658 
0659 protected:
0660     // Event handlers
0661     bool event(QEvent *event) override;
0662     virtual void mousePressEvent(QMouseEvent *event);
0663     virtual void mouseReleaseEvent(QMouseEvent *event);
0664     virtual void mouseDoubleClickEvent(QMouseEvent *event);
0665     virtual void mouseMoveEvent(QMouseEvent *event);
0666 #if QT_CONFIG(wheelevent)
0667     virtual void wheelEvent(QWheelEvent *event);
0668 #endif
0669     virtual void keyPressEvent(QKeyEvent *event);
0670     virtual void keyReleaseEvent(QKeyEvent *event);
0671     virtual void focusInEvent(QFocusEvent *event);
0672     virtual void focusOutEvent(QFocusEvent *event);
0673     virtual void enterEvent(QEnterEvent *event);
0674     virtual void leaveEvent(QEvent *event);
0675     virtual void paintEvent(QPaintEvent *event);
0676     virtual void moveEvent(QMoveEvent *event);
0677     virtual void resizeEvent(QResizeEvent *event);
0678     virtual void closeEvent(QCloseEvent *event);
0679 #ifndef QT_NO_CONTEXTMENU
0680     virtual void contextMenuEvent(QContextMenuEvent *event);
0681 #endif
0682 #if QT_CONFIG(tabletevent)
0683     virtual void tabletEvent(QTabletEvent *event);
0684 #endif
0685 #ifndef QT_NO_ACTION
0686     virtual void actionEvent(QActionEvent *event);
0687 #endif
0688 
0689 #if QT_CONFIG(draganddrop)
0690     virtual void dragEnterEvent(QDragEnterEvent *event);
0691     virtual void dragMoveEvent(QDragMoveEvent *event);
0692     virtual void dragLeaveEvent(QDragLeaveEvent *event);
0693     virtual void dropEvent(QDropEvent *event);
0694 #endif
0695 
0696     virtual void showEvent(QShowEvent *event);
0697     virtual void hideEvent(QHideEvent *event);
0698 
0699     virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
0700 
0701     // Misc. protected functions
0702     virtual void changeEvent(QEvent *);
0703 
0704     int metric(PaintDeviceMetric) const override;
0705     void initPainter(QPainter *painter) const override;
0706     QPaintDevice *redirected(QPoint *offset) const override;
0707     QPainter *sharedPainter() const override;
0708 
0709     virtual void inputMethodEvent(QInputMethodEvent *);
0710 public:
0711     virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
0712 
0713     Qt::InputMethodHints inputMethodHints() const;
0714     void setInputMethodHints(Qt::InputMethodHints hints);
0715 
0716 protected Q_SLOTS:
0717     void updateMicroFocus(Qt::InputMethodQuery query = Qt::ImQueryAll);
0718 protected:
0719 
0720     void create(WId = 0, bool initializeWindow = true,
0721                          bool destroyOldWindow = true);
0722     void destroy(bool destroyWindow = true,
0723                  bool destroySubWindows = true);
0724 
0725     friend class QDataWidgetMapperPrivate; // for access to focusNextPrevChild
0726     virtual bool focusNextPrevChild(bool next);
0727     inline bool focusNextChild() { return focusNextPrevChild(true); }
0728     inline bool focusPreviousChild() { return focusNextPrevChild(false); }
0729 
0730 protected:
0731     QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
0732 private:
0733     void setBackingStore(QBackingStore *store);
0734 
0735     bool testAttribute_helper(Qt::WidgetAttribute) const;
0736 
0737     QLayout *takeLayout();
0738 
0739     friend class QBackingStoreDevice;
0740     friend class QWidgetRepaintManager;
0741     friend class QApplication;
0742     friend class QApplicationPrivate;
0743     friend class QGuiApplication;
0744     friend class QGuiApplicationPrivate;
0745     friend class QBaseApplication;
0746     friend class QPainter;
0747     friend class QPainterPrivate;
0748     friend class QPixmap; // for QPixmap::fill()
0749     friend class QFontMetrics;
0750     friend class QFontInfo;
0751     friend class QLayout;
0752     friend class QWidgetItem;
0753     friend class QWidgetItemV2;
0754     friend class QX11PaintEngine;
0755     friend class QWin32PaintEngine;
0756     friend class QShortcutPrivate;
0757     friend class QWindowSurface;
0758     friend class QGraphicsProxyWidget;
0759     friend class QGraphicsProxyWidgetPrivate;
0760     friend class QStyleSheetStyle;
0761     friend struct QWidgetExceptionCleaner;
0762     friend class QWidgetWindow;
0763     friend class QAccessibleWidget;
0764     friend class QAccessibleTable;
0765     friend class QAccessibleTabButton;
0766 #ifndef QT_NO_GESTURES
0767     friend class QGestureManager;
0768     friend class QWinNativePanGestureRecognizer;
0769 #endif // QT_NO_GESTURES
0770     friend class QWidgetEffectSourcePrivate;
0771 
0772     friend Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
0773     friend Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
0774 
0775 private:
0776     Q_DISABLE_COPY(QWidget)
0777     Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
0778     Q_PRIVATE_SLOT(d_func(), QWindow *_q_closestWindowHandle())
0779 
0780     QWidgetData *data;
0781 };
0782 
0783 Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
0784 
0785 #ifndef Q_QDOC
0786 template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
0787 {
0788     if (!o || !o->isWidgetType()) return nullptr;
0789     return static_cast<QWidget*>(o);
0790 }
0791 template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
0792 {
0793     if (!o || !o->isWidgetType()) return nullptr;
0794     return static_cast<const QWidget*>(o);
0795 }
0796 #endif // !Q_QDOC
0797 
0798 inline QWidget *QWidget::childAt(int ax, int ay) const
0799 { return childAt(QPoint(ax, ay)); }
0800 
0801 inline Qt::WindowType QWidget::windowType() const
0802 { return static_cast<Qt::WindowType>((data->window_flags & Qt::WindowType_Mask).toInt()); }
0803 inline Qt::WindowFlags QWidget::windowFlags() const
0804 { return data->window_flags; }
0805 
0806 #if QT_DEPRECATED_SINCE(6, 1)
0807 inline bool QWidget::isTopLevel() const
0808 { return bool(windowType() & Qt::Window); }
0809 #endif
0810 
0811 inline bool QWidget::isWindow() const
0812 { return bool(windowType() & Qt::Window); }
0813 
0814 inline bool QWidget::isEnabled() const
0815 { return !testAttribute(Qt::WA_Disabled); }
0816 
0817 inline bool QWidget::isModal() const
0818 { return data->window_modality != Qt::NonModal; }
0819 
0820 inline int QWidget::minimumWidth() const
0821 { return minimumSize().width(); }
0822 
0823 inline int QWidget::minimumHeight() const
0824 { return minimumSize().height(); }
0825 
0826 inline int QWidget::maximumWidth() const
0827 { return maximumSize().width(); }
0828 
0829 inline int QWidget::maximumHeight() const
0830 { return maximumSize().height(); }
0831 
0832 inline void QWidget::setMinimumSize(const QSize &s)
0833 { setMinimumSize(s.width(),s.height()); }
0834 
0835 inline void QWidget::setMaximumSize(const QSize &s)
0836 { setMaximumSize(s.width(),s.height()); }
0837 
0838 inline void QWidget::setSizeIncrement(const QSize &s)
0839 { setSizeIncrement(s.width(),s.height()); }
0840 
0841 inline void QWidget::setBaseSize(const QSize &s)
0842 { setBaseSize(s.width(),s.height()); }
0843 
0844 inline const QFont &QWidget::font() const
0845 { return data->fnt; }
0846 
0847 inline QFontMetrics QWidget::fontMetrics() const
0848 { return QFontMetrics(data->fnt); }
0849 
0850 inline QFontInfo QWidget::fontInfo() const
0851 { return QFontInfo(data->fnt); }
0852 
0853 inline void QWidget::setMouseTracking(bool enable)
0854 { setAttribute(Qt::WA_MouseTracking, enable); }
0855 
0856 inline bool QWidget::hasMouseTracking() const
0857 { return testAttribute(Qt::WA_MouseTracking); }
0858 
0859 inline bool QWidget::underMouse() const
0860 { return testAttribute(Qt::WA_UnderMouse); }
0861 
0862 inline void QWidget::setTabletTracking(bool enable)
0863 { setAttribute(Qt::WA_TabletTracking, enable); }
0864 
0865 inline bool QWidget::hasTabletTracking() const
0866 { return testAttribute(Qt::WA_TabletTracking); }
0867 
0868 inline bool QWidget::updatesEnabled() const
0869 { return !testAttribute(Qt::WA_UpdatesDisabled); }
0870 
0871 inline void QWidget::update(int ax, int ay, int aw, int ah)
0872 { update(QRect(ax, ay, aw, ah)); }
0873 
0874 inline bool QWidget::isVisible() const
0875 { return testAttribute(Qt::WA_WState_Visible); }
0876 
0877 inline bool QWidget::isHidden() const
0878 { return testAttribute(Qt::WA_WState_Hidden); }
0879 
0880 inline void QWidget::move(int ax, int ay)
0881 { move(QPoint(ax, ay)); }
0882 
0883 inline void QWidget::resize(int w, int h)
0884 { resize(QSize(w, h)); }
0885 
0886 inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
0887 { setGeometry(QRect(ax, ay, aw, ah)); }
0888 
0889 inline QRect QWidget::rect() const
0890 { return QRect(0,0,data->crect.width(),data->crect.height()); }
0891 
0892 inline const QRect &QWidget::geometry() const
0893 { return data->crect; }
0894 
0895 inline QSize QWidget::size() const
0896 { return data->crect.size(); }
0897 
0898 inline int QWidget::width() const
0899 { return data->crect.width(); }
0900 
0901 inline int QWidget::height() const
0902 { return data->crect.height(); }
0903 
0904 inline QWidget *QWidget::parentWidget() const
0905 { return static_cast<QWidget *>(QObject::parent()); }
0906 
0907 inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
0908 { setSizePolicy(QSizePolicy(hor, ver)); }
0909 
0910 inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
0911 {
0912     if (attribute < int(8*sizeof(uint)))
0913         return data->widget_attributes & (1<<attribute);
0914     return testAttribute_helper(attribute);
0915 }
0916 
0917 #define QWIDGETSIZE_MAX ((1<<24)-1)
0918 
0919 #ifndef QT_NO_DEBUG_STREAM
0920 Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *);
0921 #endif
0922 
0923 QT_END_NAMESPACE
0924 
0925 #endif // QWIDGET_H