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 /examples | |
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 'examples')
-rw-r--r-- | examples/embeddedqwindow/main.mm | 14 | ||||
-rw-r--r-- | examples/embeddedqwindow/window.cpp | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/examples/embeddedqwindow/main.mm b/examples/embeddedqwindow/main.mm index 89ae8b8..810d789 100644 --- a/examples/embeddedqwindow/main.mm +++ b/examples/embeddedqwindow/main.mm @@ -50,17 +50,17 @@ 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 QPlatformNativeInterface *platformNativeInterface = QGuiApplication::platformNativeInterface(); + + // Inform the window that it's a "guest" of a non-QWindow + typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded); + reinterpret_cast<SetEmbeddedInForeignViewFunction>(platformNativeInterface-> + nativeResourceFunctionForIntegration("setEmbeddedInForeignView"))(qtWindow->handle(), true); + + // Get the Qt content NSView for the QWindow from the Qt platform plugin NSView *qtView = (NSView *)platformNativeInterface->nativeResourceForWindow("nsview", qtWindow); return qtView; // qtView is ready for use. } diff --git a/examples/embeddedqwindow/window.cpp b/examples/embeddedqwindow/window.cpp index 8ae918c..1868591 100644 --- a/examples/embeddedqwindow/window.cpp +++ b/examples/embeddedqwindow/window.cpp @@ -59,6 +59,7 @@ QColor colorTable[] = Window::Window(QScreen *screen) : QWindow(screen) , m_backgroundColorIndex(colorIndexId++) + , m_backingStore(0) { initialize(); } @@ -66,6 +67,7 @@ Window::Window(QScreen *screen) Window::Window(QWindow *parent) : QWindow(parent) , m_backgroundColorIndex(colorIndexId++) + , m_backingStore(0) { initialize(); } @@ -181,6 +183,8 @@ void Window::timerEvent(QTimerEvent *) void Window::render() { + if (!m_backingStore) + return; QRect rect(QPoint(), geometry().size()); m_backingStore->resize(rect.size()); |