Warning, file /include/QtGui/qwindow.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QWINDOW_H
0005 #define QWINDOW_H
0006
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/QObject>
0009 #include <QtCore/QEvent>
0010 #include <QtCore/QMargins>
0011 #include <QtCore/QRect>
0012
0013 #include <QtCore/qnamespace.h>
0014 #include <QtCore/qnativeinterface.h>
0015
0016 #include <QtGui/qsurface.h>
0017 #include <QtGui/qsurfaceformat.h>
0018 #include <QtGui/qwindowdefs.h>
0019
0020 #include <QtGui/qicon.h>
0021
0022 #ifndef QT_NO_CURSOR
0023 #include <QtGui/qcursor.h>
0024 #endif
0025
0026 QT_BEGIN_NAMESPACE
0027
0028
0029 class QWindowPrivate;
0030
0031 class QExposeEvent;
0032 class QPaintEvent;
0033 class QFocusEvent;
0034 class QMoveEvent;
0035 class QResizeEvent;
0036 class QShowEvent;
0037 class QHideEvent;
0038 class QCloseEvent;
0039 class QKeyEvent;
0040 class QMouseEvent;
0041 #if QT_CONFIG(wheelevent)
0042 class QWheelEvent;
0043 #endif
0044 class QTouchEvent;
0045 #if QT_CONFIG(tabletevent)
0046 class QTabletEvent;
0047 #endif
0048
0049 class QPlatformSurface;
0050 class QPlatformWindow;
0051 class QBackingStore;
0052 class QScreen;
0053 class QAccessibleInterface;
0054 class QWindowContainer;
0055 #ifndef QT_NO_DEBUG_STREAM
0056 class QDebug;
0057 #endif
0058 #if QT_CONFIG(vulkan) || defined(Q_QDOC)
0059 class QVulkanInstance;
0060 #endif
0061
0062 class Q_GUI_EXPORT QWindow : public QObject, public QSurface
0063 {
0064 Q_OBJECT
0065 Q_DECLARE_PRIVATE(QWindow)
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY windowTitleChanged)
0078 Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
0079 Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags)
0080 Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
0081 Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
0082 Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
0083 Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
0084 Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
0085 Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight
0086 NOTIFY minimumHeightChanged)
0087 Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
0088 Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight
0089 NOTIFY maximumHeightChanged)
0090 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
0091 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged REVISION(2, 1))
0092 Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged
0093 REVISION(2, 1))
0094 Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation
0095 WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
0096 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION(2, 1))
0097 #ifdef Q_QDOC
0098 Q_PROPERTY(QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
0099 #else
0100 Q_PRIVATE_PROPERTY(QWindow::d_func(), QWindow* transientParent MEMBER transientParent
0101 WRITE setTransientParent NOTIFY transientParentChanged REVISION(2, 13))
0102 #endif
0103
0104 public:
0105 enum Visibility {
0106 Hidden = 0,
0107 AutomaticVisibility,
0108 Windowed,
0109 Minimized,
0110 Maximized,
0111 FullScreen
0112 };
0113 Q_ENUM(Visibility)
0114
0115 enum AncestorMode {
0116 ExcludeTransients,
0117 IncludeTransients
0118 };
0119 Q_ENUM(AncestorMode)
0120
0121 explicit QWindow(QScreen *screen = nullptr);
0122 explicit QWindow(QWindow *parent);
0123 ~QWindow();
0124
0125 void setSurfaceType(SurfaceType surfaceType);
0126 SurfaceType surfaceType() const override;
0127
0128 bool isVisible() const;
0129
0130 Visibility visibility() const;
0131 void setVisibility(Visibility v);
0132
0133 void create();
0134
0135 WId winId() const;
0136
0137 QWindow *parent(AncestorMode mode = ExcludeTransients) const;
0138 void setParent(QWindow *parent);
0139
0140 bool isTopLevel() const;
0141
0142 bool isModal() const;
0143 Qt::WindowModality modality() const;
0144 void setModality(Qt::WindowModality modality);
0145
0146 void setFormat(const QSurfaceFormat &format);
0147 QSurfaceFormat format() const override;
0148 QSurfaceFormat requestedFormat() const;
0149
0150 void setFlags(Qt::WindowFlags flags);
0151 Qt::WindowFlags flags() const;
0152 void setFlag(Qt::WindowType, bool on = true);
0153 Qt::WindowType type() const;
0154
0155 QString title() const;
0156
0157 void setOpacity(qreal level);
0158 qreal opacity() const;
0159
0160 void setMask(const QRegion ®ion);
0161 QRegion mask() const;
0162
0163 bool isActive() const;
0164
0165 void reportContentOrientationChange(Qt::ScreenOrientation orientation);
0166 Qt::ScreenOrientation contentOrientation() const;
0167
0168 qreal devicePixelRatio() const;
0169
0170 Qt::WindowState windowState() const;
0171 Qt::WindowStates windowStates() const;
0172 void setWindowState(Qt::WindowState state);
0173 void setWindowStates(Qt::WindowStates states);
0174
0175 void setTransientParent(QWindow *parent);
0176 QWindow *transientParent() const;
0177
0178 bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
0179
0180 bool isExposed() const;
0181
0182 inline int minimumWidth() const { return minimumSize().width(); }
0183 inline int minimumHeight() const { return minimumSize().height(); }
0184 inline int maximumWidth() const { return maximumSize().width(); }
0185 inline int maximumHeight() const { return maximumSize().height(); }
0186
0187 QSize minimumSize() const;
0188 QSize maximumSize() const;
0189 QSize baseSize() const;
0190 QSize sizeIncrement() const;
0191
0192 void setMinimumSize(const QSize &size);
0193 void setMaximumSize(const QSize &size);
0194 void setBaseSize(const QSize &size);
0195 void setSizeIncrement(const QSize &size);
0196
0197 QRect geometry() const;
0198
0199 QMargins frameMargins() const;
0200 QRect frameGeometry() const;
0201
0202 QPoint framePosition() const;
0203 void setFramePosition(const QPoint &point);
0204
0205 inline int width() const { return geometry().width(); }
0206 inline int height() const { return geometry().height(); }
0207 inline int x() const { return geometry().x(); }
0208 inline int y() const { return geometry().y(); }
0209
0210 QSize size() const override { return geometry().size(); }
0211 inline QPoint position() const { return geometry().topLeft(); }
0212
0213 void setPosition(const QPoint &pt);
0214 void setPosition(int posx, int posy);
0215
0216 void resize(const QSize &newSize);
0217 void resize(int w, int h);
0218
0219 void setFilePath(const QString &filePath);
0220 QString filePath() const;
0221
0222 void setIcon(const QIcon &icon);
0223 QIcon icon() const;
0224
0225 void destroy();
0226
0227 QPlatformWindow *handle() const;
0228
0229 bool setKeyboardGrabEnabled(bool grab);
0230 bool setMouseGrabEnabled(bool grab);
0231
0232 QScreen *screen() const;
0233 void setScreen(QScreen *screen);
0234
0235 virtual QAccessibleInterface *accessibleRoot() const;
0236 virtual QObject *focusObject() const;
0237
0238 QPointF mapToGlobal(const QPointF &pos) const;
0239 QPointF mapFromGlobal(const QPointF &pos) const;
0240 QPoint mapToGlobal(const QPoint &pos) const;
0241 QPoint mapFromGlobal(const QPoint &pos) const;
0242
0243 #ifndef QT_NO_CURSOR
0244 QCursor cursor() const;
0245 void setCursor(const QCursor &);
0246 void unsetCursor();
0247 #endif
0248
0249 static QWindow *fromWinId(WId id);
0250
0251 #if QT_CONFIG(vulkan) || defined(Q_QDOC)
0252 void setVulkanInstance(QVulkanInstance *instance);
0253 QVulkanInstance *vulkanInstance() const;
0254 #endif
0255
0256 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QWindow)
0257
0258 public Q_SLOTS:
0259 Q_REVISION(2, 1) void requestActivate();
0260
0261 void setVisible(bool visible);
0262
0263 void show();
0264 void hide();
0265
0266 void showMinimized();
0267 void showMaximized();
0268 void showFullScreen();
0269 void showNormal();
0270
0271 bool close();
0272 void raise();
0273 void lower();
0274 bool startSystemResize(Qt::Edges edges);
0275 bool startSystemMove();
0276
0277 void setTitle(const QString &);
0278
0279 void setX(int arg);
0280 void setY(int arg);
0281 void setWidth(int arg);
0282 void setHeight(int arg);
0283 void setGeometry(int posx, int posy, int w, int h);
0284 void setGeometry(const QRect &rect);
0285
0286 void setMinimumWidth(int w);
0287 void setMinimumHeight(int h);
0288 void setMaximumWidth(int w);
0289 void setMaximumHeight(int h);
0290
0291 Q_REVISION(2, 1) void alert(int msec);
0292
0293 Q_REVISION(2, 3) void requestUpdate();
0294
0295 Q_SIGNALS:
0296 void screenChanged(QScreen *screen);
0297 void modalityChanged(Qt::WindowModality modality);
0298 void windowStateChanged(Qt::WindowState windowState);
0299 Q_REVISION(2, 2) void windowTitleChanged(const QString &title);
0300
0301 void xChanged(int arg);
0302 void yChanged(int arg);
0303
0304 void widthChanged(int arg);
0305 void heightChanged(int arg);
0306
0307 void minimumWidthChanged(int arg);
0308 void minimumHeightChanged(int arg);
0309 void maximumWidthChanged(int arg);
0310 void maximumHeightChanged(int arg);
0311
0312 void visibleChanged(bool arg);
0313 Q_REVISION(2, 1) void visibilityChanged(QWindow::Visibility visibility);
0314 Q_REVISION(2, 1) void activeChanged();
0315 void contentOrientationChanged(Qt::ScreenOrientation orientation);
0316
0317 void focusObjectChanged(QObject *object);
0318
0319 Q_REVISION(2, 1) void opacityChanged(qreal opacity);
0320
0321 Q_REVISION(2, 13) void transientParentChanged(QWindow *transientParent);
0322
0323 protected:
0324 virtual void exposeEvent(QExposeEvent *);
0325 virtual void resizeEvent(QResizeEvent *);
0326 virtual void paintEvent(QPaintEvent *);
0327 virtual void moveEvent(QMoveEvent *);
0328 virtual void focusInEvent(QFocusEvent *);
0329 virtual void focusOutEvent(QFocusEvent *);
0330
0331 virtual void showEvent(QShowEvent *);
0332 virtual void hideEvent(QHideEvent *);
0333 virtual void closeEvent(QCloseEvent *);
0334
0335 virtual bool event(QEvent *) override;
0336 virtual void keyPressEvent(QKeyEvent *);
0337 virtual void keyReleaseEvent(QKeyEvent *);
0338 virtual void mousePressEvent(QMouseEvent *);
0339 virtual void mouseReleaseEvent(QMouseEvent *);
0340 virtual void mouseDoubleClickEvent(QMouseEvent *);
0341 virtual void mouseMoveEvent(QMouseEvent *);
0342 #if QT_CONFIG(wheelevent)
0343 virtual void wheelEvent(QWheelEvent *);
0344 #endif
0345 virtual void touchEvent(QTouchEvent *);
0346 #if QT_CONFIG(tabletevent)
0347 virtual void tabletEvent(QTabletEvent *);
0348 #endif
0349 virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result);
0350
0351 QWindow(QWindowPrivate &dd, QWindow *parent);
0352
0353 private:
0354 Q_PRIVATE_SLOT(d_func(), void _q_clearAlert())
0355 QPlatformSurface *surfaceHandle() const override;
0356
0357 Q_DISABLE_COPY(QWindow)
0358
0359 friend class QGuiApplication;
0360 friend class QGuiApplicationPrivate;
0361 friend class QWindowContainer;
0362 friend Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window);
0363 };
0364
0365 #ifndef Q_QDOC
0366
0367 template <> inline QWindow *qobject_cast<QWindow*>(QObject *o)
0368 {
0369 if (!o || !o->isWindowType()) return nullptr;
0370 return static_cast<QWindow*>(o);
0371 }
0372 template <> inline const QWindow *qobject_cast<const QWindow*>(const QObject *o)
0373 {
0374 if (!o || !o->isWindowType()) return nullptr;
0375 return static_cast<const QWindow*>(o);
0376 }
0377 #endif
0378
0379 #ifndef QT_NO_DEBUG_STREAM
0380 Q_GUI_EXPORT QDebug operator<<(QDebug, const QWindow *);
0381 #endif
0382
0383 QT_END_NAMESPACE
0384
0385 #endif