diff options
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()); |