summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorDaniel Vrátil <daniel.vratil@kdab.com>2016-11-02 21:20:26 +0100
committerDaniel Vrátil <daniel.vratil@kdab.com>2016-11-22 12:40:33 +0000
commitbabc7c5929d5157330eb4010cf1483861528eeb8 (patch)
treece2a77a39ea6220cce1b5ade1fab536d279e6637 /src/widgets
parenta01f2112f4b88dbccd4af8c16248457376e363ab (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/widgets')
-rw-r--r--src/widgets/kernel/qwidget.cpp19
-rw-r--r--src/widgets/kernel/qwidget.h1
2 files changed, 19 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index ace50f13ee..1db9f5d75e 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -10357,7 +10357,7 @@ void QWidget::updateGeometry()
a window, causing the widget to be hidden. You must call show() to make
the widget visible again..
- \sa windowType(), {Window Flags Example}
+ \sa windowType(), setWindowFlag(), {Window Flags Example}
*/
void QWidget::setWindowFlags(Qt::WindowFlags flags)
{
@@ -10365,6 +10365,23 @@ void QWidget::setWindowFlags(Qt::WindowFlags flags)
d->setWindowFlags(flags);
}
+/*!
+ \since 5.9
+
+ Sets the window flag \a flag on this widget if \a on is true;
+ otherwise clears the flag.
+
+ \sa setWindowFlags(), windowFlags(), windowType()
+*/
+void QWidget::setWindowFlag(Qt::WindowType flag, bool on)
+{
+ Q_D(QWidget);
+ if (on)
+ d->setWindowFlags(data->window_flags | flag);
+ else
+ d->setWindowFlags(data->window_flags & ~flag);
+}
+
/*! \internal
Implemented in QWidgetPrivate so that QMdiSubWindowPrivate can reimplement it.
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 5edf2c62da..daf6b9e85b 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -562,6 +562,7 @@ public:
void setWindowFlags(Qt::WindowFlags type);
inline Qt::WindowFlags windowFlags() const;
+ void setWindowFlag(Qt::WindowType, bool on = true);
void overrideWindowFlags(Qt::WindowFlags type);
inline Qt::WindowType windowType() const;