diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-04-24 14:09:14 +0200 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2013-04-26 15:04:13 +0200 |
commit | d96bf490a0342a31343ffc88c34b715675638118 (patch) | |
tree | fc607755c73828372f2b7e93b207fa84bef5f818 /src | |
parent | e5e779c704b0695728d76d0106ec72985037e228 (diff) |
setEmbeddedInForeignView to embed a QWindow in a foreign window
Depends on https://codereview.qt-project.org/#change,54607 in qtbase
Change-Id: Id95038b0a6f3383358a4d688ee2c5e6907ebe7c0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/macextras/qmacnativewidget.mm | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/macextras/qmacnativewidget.mm b/src/macextras/qmacnativewidget.mm index 2723b68..b9963ab 100644 --- a/src/macextras/qmacnativewidget.mm +++ b/src/macextras/qmacnativewidget.mm @@ -72,16 +72,17 @@ QT_BEGIN_NAMESPACE #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) NSView *getEmbeddableView(QWindow *qtWindow) { - // Set Qt::SubWindow flag. Should be done before crate() is - // called - if you call create() or caused it ot be called - // before calling this function you need to set SubWindow - // yourself - qtWindow->setFlags(qtWindow->flags() | Qt::SubWindow); - // Make sure the platform window is created qtWindow->create(); - // Get the Qt content NSView for the QWindow forom the Qt platform plugin + // Inform the window that it's a subwindow of a non-Qt window. This must be + // done after create() because we need to have a QPlatformWindow instance. + // The corresponding NSWindow will not be shown and can be deleted later. + extern QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePlatformFunction(const QByteArray &functionName); + typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded); + reinterpret_cast<SetEmbeddedInForeignViewFunction>(resolvePlatformFunction("setEmbeddedInForeignView"))(qtWindow->handle(), true); + + // Get the Qt content NSView for the QWindow from the Qt platform plugin QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow); return qtView; // qtView is ready for use. @@ -93,7 +94,7 @@ NSView *getEmbeddableView(QWindow *qtWindow) parent). The \a parentView is a NSView pointer. */ QMacNativeWidget::QMacNativeWidget(NSView *parentView) - : QWidget(0, Qt::Window | Qt::SubWindow) + : QWidget(0) { Q_UNUSED(parentView); |