summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/kernel.pri6
-rw-r--r--src/widgets/kernel/qaction.h4
-rw-r--r--src/widgets/kernel/qactiongroup.h4
-rw-r--r--src/widgets/kernel/qapplication.cpp4
-rw-r--r--src/widgets/kernel/qapplication.h4
-rw-r--r--src/widgets/kernel/qboxlayout.h4
-rw-r--r--src/widgets/kernel/qdesktopwidget.h4
-rw-r--r--src/widgets/kernel/qformlayout.h4
-rw-r--r--src/widgets/kernel/qgesture.h4
-rw-r--r--src/widgets/kernel/qgesturerecognizer.h4
-rw-r--r--src/widgets/kernel/qgridlayout.h4
-rw-r--r--src/widgets/kernel/qlayout.h4
-rw-r--r--src/widgets/kernel/qlayoutitem.h6
-rw-r--r--src/widgets/kernel/qshortcut.h4
-rw-r--r--src/widgets/kernel/qsizepolicy.h4
-rw-r--r--src/widgets/kernel/qstackedlayout.h4
-rw-r--r--src/widgets/kernel/qtooltip.h4
-rw-r--r--src/widgets/kernel/qwhatsthis.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp15
-rw-r--r--src/widgets/kernel/qwidget.h6
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp10
-rw-r--r--src/widgets/kernel/qwidgetaction.h4
-rw-r--r--src/widgets/kernel/qwidgetsfunctions_wince.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp15
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa_p.h4
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp218
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h69
27 files changed, 329 insertions, 90 deletions
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri
index 4d3d7c4e0a..533b696faa 100644
--- a/src/widgets/kernel/kernel.pri
+++ b/src/widgets/kernel/kernel.pri
@@ -34,7 +34,8 @@ HEADERS += \
kernel/qgesturerecognizer.h \
kernel/qgesturemanager_p.h \
kernel/qdesktopwidget_qpa_p.h \
- kernel/qwidgetwindow_qpa_p.h
+ kernel/qwidgetwindow_qpa_p.h \
+ kernel/qwindowcontainer_p.h
SOURCES += \
kernel/qaction.cpp \
@@ -62,7 +63,8 @@ SOURCES += \
kernel/qapplication_qpa.cpp \
kernel/qdesktopwidget_qpa.cpp \
kernel/qwidget_qpa.cpp \
- kernel/qwidgetwindow.cpp
+ kernel/qwidgetwindow.cpp \
+ kernel/qwindowcontainer.cpp
# TODO
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 5fb4c655eb..975073201a 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -48,8 +48,6 @@
#include <QtCore/qvariant.h>
#include <QtGui/qicon.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -221,6 +219,4 @@ QT_END_INCLUDE_NAMESPACE
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACTION_H
diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h
index 13c5ea8ef1..747cc83865 100644
--- a/src/widgets/kernel/qactiongroup.h
+++ b/src/widgets/kernel/qactiongroup.h
@@ -44,8 +44,6 @@
#include <QtWidgets/qaction.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -99,6 +97,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QACTIONGROUP_H
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 4c6d8cfdc7..cff75f258e 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3560,8 +3560,8 @@ int QApplication::doubleClickInterval()
\since 4.2
\deprecated
- Returns the current keyboard input direction. Replaced with QInputPanel::inputDirection()
- \sa QInputPanel::inputDirection()
+ Returns the current keyboard input direction. Replaced with QInputMethod::inputDirection()
+ \sa QInputMethod::inputDirection()
*/
/*!
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 29f5ddf455..07ee638738 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -55,8 +55,6 @@
#endif
#include <QtGui/qguiapplication.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -247,6 +245,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QAPPLICATION_H
diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h
index 3ced397c1d..dabb96ccd8 100644
--- a/src/widgets/kernel/qboxlayout.h
+++ b/src/widgets/kernel/qboxlayout.h
@@ -49,8 +49,6 @@
#include <limits.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -141,6 +139,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QBOXLAYOUT_H
diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h
index c27e96a2d9..d823e3ce47 100644
--- a/src/widgets/kernel/qdesktopwidget.h
+++ b/src/widgets/kernel/qdesktopwidget.h
@@ -44,8 +44,6 @@
#include <QtWidgets/qwidget.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -104,6 +102,4 @@ inline int QDesktopWidget::screenCount() const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QDESKTOPWIDGET_H
diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h
index a206e90009..29abc6b548 100644
--- a/src/widgets/kernel/qformlayout.h
+++ b/src/widgets/kernel/qformlayout.h
@@ -44,8 +44,6 @@
#include <QtWidgets/QLayout>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -157,6 +155,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
index 4384600f80..a9609ffad9 100644
--- a/src/widgets/kernel/qgesture.h
+++ b/src/widgets/kernel/qgesture.h
@@ -52,8 +52,6 @@
#ifndef QT_NO_GESTURES
-QT_BEGIN_HEADER
-
Q_DECLARE_METATYPE(Qt::GestureState)
Q_DECLARE_METATYPE(Qt::GestureType)
@@ -328,8 +326,6 @@ private:
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
-QT_END_HEADER
-
#endif // QT_NO_GESTURES
#endif // QGESTURE_H
diff --git a/src/widgets/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h
index b85aa54a6b..e313920f0a 100644
--- a/src/widgets/kernel/qgesturerecognizer.h
+++ b/src/widgets/kernel/qgesturerecognizer.h
@@ -47,8 +47,6 @@
#ifndef QT_NO_GESTURES
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -94,8 +92,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QGestureRecognizer::Result)
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QT_NO_GESTURES
#endif // QGESTURERECOGNIZER_H
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
index 9349c7807d..39c26619c3 100644
--- a/src/widgets/kernel/qgridlayout.h
+++ b/src/widgets/kernel/qgridlayout.h
@@ -49,8 +49,6 @@
#include <limits.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -132,6 +130,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QGRIDLAYOUT_H
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index 09ddebeb2a..3f09419b05 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -50,8 +50,6 @@
#include <limits.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -171,6 +169,4 @@ QT_END_NAMESPACE
#include <QtWidgets/qboxlayout.h>
#include <QtWidgets/qgridlayout.h>
-QT_END_HEADER
-
#endif // QLAYOUT_H
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index b19a7c789f..808cc9ff5d 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -47,12 +47,10 @@
#include <limits.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
-static const int QLAYOUTSIZE_MAX = INT_MAX/256/16;
+static const Q_DECL_UNUSED int QLAYOUTSIZE_MAX = INT_MAX/256/16;
class QLayout;
class QLayoutItem;
@@ -180,6 +178,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QLAYOUTITEM_H
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index f5daa381f7..001c6814ee 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -45,8 +45,6 @@
#include <QtWidgets/qwidget.h>
#include <QtGui/qkeysequence.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -101,6 +99,4 @@ protected:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSHORTCUT_H
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 0a878674cc..383c7d0512 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -44,8 +44,6 @@
#include <QtCore/qobject.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -183,6 +181,4 @@ inline void QSizePolicy::transpose() {
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSIZEPOLICY_H
diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h
index a8067b5bab..5067f4e457 100644
--- a/src/widgets/kernel/qstackedlayout.h
+++ b/src/widgets/kernel/qstackedlayout.h
@@ -44,8 +44,6 @@
#include <QtWidgets/qlayout.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -111,6 +109,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QSTACKEDLAYOUT_H
diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h
index 3a09803598..c7fb9809dc 100644
--- a/src/widgets/kernel/qtooltip.h
+++ b/src/widgets/kernel/qtooltip.h
@@ -44,8 +44,6 @@
#include <QtWidgets/qwidget.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -72,6 +70,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QTOOLTIP_H
diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h
index 7e41e5ab58..80a8be5227 100644
--- a/src/widgets/kernel/qwhatsthis.h
+++ b/src/widgets/kernel/qwhatsthis.h
@@ -45,8 +45,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qcursor.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -74,6 +72,4 @@ public:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWHATSTHIS_H
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 5ec713140e..823403c4a6 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6916,14 +6916,15 @@ void QWidget::setUpdatesEnabled(bool enable)
Shows the widget and its child widgets. This function is
equivalent to setVisible(true) in the normal case, and equivalent
to showFullScreen() if the QStyleHints::showIsFullScreen() hint
- is true.
+ is true and the window is not a popup.
\sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
- showNormal(), isVisible()
+ showNormal(), isVisible(), windowFlags()
*/
void QWidget::show()
{
- if (isWindow() && qApp->styleHints()->showIsFullScreen())
+ bool isPopup = data->window_flags & Qt::Popup & ~Qt::Window;
+ if (isWindow() && !isPopup && qApp->styleHints()->showIsFullScreen())
showFullScreen();
else
setVisible(true);
@@ -8574,6 +8575,10 @@ void QWidget::focusOutEvent(QFocusEvent *)
{
if (focusPolicy() != Qt::NoFocus || !isWindow())
update();
+
+ // automatically hide the SIP
+ if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
+ qApp->inputMethod()->hide();
}
/*!
@@ -8796,7 +8801,7 @@ void QWidget::inputMethodEvent(QInputMethodEvent *event)
\a query specifies which property is queried.
- \sa inputMethodEvent(), QInputMethodEven, inputMethodHints
+ \sa inputMethodEvent(), QInputMethodEvent, QInputMethodQueryEvent, inputMethodHints
*/
QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
{
@@ -9096,7 +9101,7 @@ QLayout *QWidget::layout() const
existing layout manager (returned by layout()) before you can
call setLayout() with the new layout.
- If \a layout is the layout manger on a different widget, setLayout()
+ If \a layout is the layout manager on a different widget, setLayout()
will reparent the layout and make it the layout manager for this widget.
Example:
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 25dac1ed5e..5965eb8601 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -60,8 +60,6 @@
#include <QtGui/qevent.h>
#endif
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -593,6 +591,8 @@ public:
QWindow *windowHandle() const;
+ static QWidget *createWindowContainer(QWindow *window, QWidget *parent=0, Qt::WindowFlags flags=0);
+
friend class QDesktopScreenWidget;
Q_SIGNALS:
@@ -855,6 +855,4 @@ inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWIDGET_H
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index 84693d02a5..554148675e 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -999,6 +999,12 @@ static inline void applyCursor(QWidget *w, QCursor c)
window->setCursor(c);
}
+static inline void unsetCursor(QWidget *w)
+{
+ if (QWindow *window = w->windowHandle())
+ window->unsetCursor();
+}
+
void qt_qpa_set_cursor(QWidget *w, bool force)
{
if (!w->testAttribute(Qt::WA_WState_Created))
@@ -1032,9 +1038,9 @@ void qt_qpa_set_cursor(QWidget *w, bool force)
else
// Enforce the windows behavior of clearing the cursor on
// disabled widgets.
- applyCursor(nativeParent, Qt::ArrowCursor);
+ unsetCursor(nativeParent);
} else {
- applyCursor(nativeParent, Qt::ArrowCursor);
+ unsetCursor(nativeParent);
}
}
#endif //QT_NO_CURSOR
diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h
index 14f1bfaf7f..3956445bc8 100644
--- a/src/widgets/kernel/qwidgetaction.h
+++ b/src/widgets/kernel/qwidgetaction.h
@@ -44,8 +44,6 @@
#include <QtWidgets/qaction.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -85,6 +83,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWIDGETACTION_H
diff --git a/src/widgets/kernel/qwidgetsfunctions_wince.h b/src/widgets/kernel/qwidgetsfunctions_wince.h
index 5d3640ae75..cc8c1e4a03 100644
--- a/src/widgets/kernel/qwidgetsfunctions_wince.h
+++ b/src/widgets/kernel/qwidgetsfunctions_wince.h
@@ -44,10 +44,8 @@
#include <QtCore/qfunctions_wince.h>
#ifdef QT_BUILD_GUI_LIB
-QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
-QT_END_HEADER
#endif
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 50b61beb05..d7b9d8c5fb 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -352,6 +352,21 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
&& qt_replay_popup_mouse_event) {
if (m_widget->windowType() != Qt::Popup)
qt_button_down = 0;
+ if (event->type() == QEvent::MouseButtonPress) {
+ // the popup disappeared, replay the mouse press event
+ QWidget *w = QApplication::widgetAt(event->globalPos());
+ if (w && !QApplicationPrivate::isBlockedByModal(w)) {
+ QWindow *win = w->windowHandle();
+ if (!win)
+ win = w->nativeParentWidget()->windowHandle();
+ if (win && win->geometry().contains(event->globalPos())) {
+ const QPoint localPos = win->mapFromGlobal(event->globalPos());
+ QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ e.setTimestamp(event->timestamp());
+ QApplication::sendSpontaneousEvent(win, &e);
+ }
+ }
+ }
qt_replay_popup_mouse_event = false;
#ifndef QT_NO_CONTEXTMENU
} else if (event->type() == QEvent::MouseButtonPress
diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h
index 7e40ded8c8..84c1b90826 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa_p.h
+++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h
@@ -47,8 +47,6 @@
#include <QtCore/private/qobject_p.h>
#include <QtGui/private/qevent_p.h>
-QT_BEGIN_HEADER
-
QT_BEGIN_NAMESPACE
@@ -111,6 +109,4 @@ private:
QT_END_NAMESPACE
-QT_END_HEADER
-
#endif // QWIDGETWINDOW_QPA_P_H
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
new file mode 100644
index 0000000000..81322f49b4
--- /dev/null
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -0,0 +1,218 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowcontainer_p.h"
+#include "qwidget_p.h"
+#include <QtGui/qwindow.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindowContainerPrivate : public QWidgetPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QWindowContainer)
+
+ QWindowContainerPrivate() : window(0), oldFocusWindow(0) { }
+ ~QWindowContainerPrivate() { }
+
+ QPointer<QWindow> window;
+ QWindow *oldFocusWindow;
+};
+
+
+
+/*!
+ \fn QWidget *QWidget::createWindowContainer(QWindow *window, QWidget *parent, Qt::WindowFlags flags);
+
+ Creates a QWidget that makes it possible to embed \a window into
+ a QWidget-based application.
+
+ The window container is created as a child of \a parent and with
+ window flags \a flags.
+
+ Once the window has been embedded into the container, the
+ container will control the window's geometry and
+ visibility. Explicit calls to QWindow::setGeometry(),
+ QWindow::show() or QWindow::hide() on an embedded window is not
+ recommended.
+
+ The container takes over ownership of \a window. The window can
+ be removed from the window container with a call to
+ QWindow::setParent().
+
+ The window container has a number of known limitations:
+
+ \list
+
+ \li Stacking order; The embedded window will stack on top of the
+ widget hierarchy as an opaque box. The stacking order of multiple
+ overlapping window container instances is undefined.
+
+ \li Window Handles; The window container will explicitly invoke
+ winId() which will force the use of native window handles
+ inside the application. See \l {Native Widgets vs Alien Widgets}
+ {QWidget documentation} for more details.
+
+ \li Rendering Integration; The window container does not interoperate
+ with QGraphicsProxyWidget, QWidget::render() or similar functionality.
+
+ \li Focus Handling; It is possible to let the window container
+ instance have any focus policy and it will delegate focus to the
+ window via a call to QWindow::requestActivate(). However,
+ returning to the normal focus chain from the QWindow instance will
+ be up to the QWindow instance implementation itself. For instance,
+ when entering a Qt Quick based window with tab focus, it is quite
+ likely that further tab presses will only cycle inside the QML
+ application. Also, whether QWindow::requestActivate() actually
+ gives the window focus, is platform dependent.
+
+ \li Using many window container instances in a QWidget-based
+ application can greatly hurt the overall performance of the
+ application.
+
+ \endlist
+ */
+
+QWidget *QWidget::createWindowContainer(QWindow *window, QWidget *parent, Qt::WindowFlags flags)
+{
+ return new QWindowContainer(window, parent, flags);
+}
+
+
+
+/*!
+ \internal
+ */
+
+QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt::WindowFlags flags)
+ : QWidget(*new QWindowContainerPrivate, parent, flags)
+{
+ Q_D(QWindowContainer);
+ if (!embeddedWindow) {
+ qWarning("QWindowContainer: embedded window cannot be null");
+ return;
+ }
+
+ d->window = embeddedWindow;
+
+ // We force this window to become a native window and reparent the
+ // window directly to it. This is done so that the order in which
+ // the QWindowContainer is added to a QWidget tree and when it
+ // gets a window does not matter.
+ winId();
+ d->window->setParent(windowHandle());
+
+ connect(QGuiApplication::instance(), SIGNAL(focusWindowChanged(QWindow *)), this, SLOT(focusWindowChanged(QWindow *)));
+}
+
+
+
+/*!
+ \internal
+ */
+
+QWindowContainer::~QWindowContainer()
+{
+ Q_D(QWindowContainer);
+ delete d->window;
+}
+
+
+
+/*!
+ \internal
+ */
+
+void QWindowContainer::focusWindowChanged(QWindow *focusWindow)
+{
+ Q_D(QWindowContainer);
+ d->oldFocusWindow = focusWindow;
+}
+
+
+
+/*!
+ \internal
+ */
+
+bool QWindowContainer::event(QEvent *e)
+{
+ Q_D(QWindowContainer);
+ if (!d->window)
+ return QWidget::event(e);
+
+ QEvent::Type type = e->type();
+ switch (type) {
+ case QEvent::ChildRemoved: {
+ QChildEvent *ce = static_cast<QChildEvent *>(e);
+ if (ce->child() == d->window)
+ d->window = 0;
+ break;
+ }
+ // The only thing we are interested in is making sure our sizes stay
+ // in sync, so do a catch-all case.
+ case QEvent::Resize:
+ case QEvent::Move:
+ case QEvent::PolishRequest:
+ d->window->setGeometry(0, 0, width(), height());
+ break;
+ case QEvent::Show:
+ d->window->show();
+ break;
+ case QEvent::Hide:
+ d->window->hide();
+ break;
+ case QEvent::FocusIn:
+ if (d->oldFocusWindow != d->window) {
+ d->window->requestActivate();
+ } else {
+ QWidget *next = nextInFocusChain();
+ next->setFocus();
+ }
+ break;
+ default:
+ break;
+ }
+
+ return QWidget::event(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
new file mode 100644
index 0000000000..e8d089c9bd
--- /dev/null
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWCONTAINER_H
+#define QWINDOWCONTAINER_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWindowContainerPrivate;
+
+class QWindowContainer : public QWidget
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWindowContainer)
+
+public:
+ explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0);
+ ~QWindowContainer();
+
+protected:
+ bool event(QEvent *ev);
+
+private slots:
+ void focusWindowChanged(QWindow *focusWindow);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWCONTAINER_H