diff options
author | Daniel Vrátil <daniel.vratil@kdab.com> | 2016-11-02 21:20:26 +0100 |
---|---|---|
committer | Daniel Vrátil <daniel.vratil@kdab.com> | 2016-11-22 12:40:33 +0000 |
commit | babc7c5929d5157330eb4010cf1483861528eeb8 (patch) | |
tree | ce2a77a39ea6220cce1b5ade1fab536d279e6637 /src/gui/kernel | |
parent | a01f2112f4b88dbccd4af8c16248457376e363ab (diff) |
Introduce QWindow::setFlag and QWidget::setWindowFlag
Analogous to QWidget::setAttribute(), introduce an API to easily
enable/disable a single window flag without having to resort to
w.setFlags(w.flags() | Qt::NewFlag).
Change-Id: Ib0f7254a34c8d884cdec181c41b99e5ef035d954
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 124e997c58..4822793ae7 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -821,6 +821,8 @@ QSurfaceFormat QWindow::format() const The actual window flags might differ from the flags set with setFlags() if the requested flags could not be fulfilled. + + \sa setFlag() */ void QWindow::setFlags(Qt::WindowFlags flags) { @@ -840,6 +842,23 @@ Qt::WindowFlags QWindow::flags() const } /*! + \since 5.9 + + Sets the window flag \a flag on this window if \a on is true; + otherwise clears the flag. + + \sa setFlags(), flags(), type() +*/ +void QWindow::setFlag(Qt::WindowType flag, bool on) +{ + Q_D(QWindow); + if (on) + setFlags(d->windowFlags | flag); + else + setFlags(d->windowFlags & ~flag); +} + +/*! Returns the type of the window. This returns the part of the window flags that represents diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index bf25cf64c9..0b84f30468 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -163,6 +163,7 @@ public: void setFlags(Qt::WindowFlags flags); Qt::WindowFlags flags() const; + void setFlag(Qt::WindowType, bool on = true); Qt::WindowType type() const; QString title() const; |