Hi Tim, On Dec 9, 2013, at 1:33 PM, Tim Blechmann <t...@klingt.org<mailto:t...@klingt.org>> wrote:
trying to embed a Qt widget hierarchy into a Cocoa hierarchy, i'm currently trying to figure out how the memory management is supposed to work: i've adapted the example [1] to add a RedWidget to the layout. it gets allocated in the applicationDidFinishLaunching method, but for some reason it is never destroyed. so i wonder, is this a bug or a feature? or more generally speaking: will the QMacNativeWidget automatically be destroyed when its parent NSView* is destroyed? if not, what is the preferred way to make sure that it is destroyed correctly? While the QMacNativeWidget’s underlying NSView will be destroyed by Cocoa when its parent view is, that NSView does NOT take ownership of any QWidget (Note that you should not cache the NSView pointer unless you’re sure about its lifespan. Furthermore, calling “QMacNativeWidget::nativeView()” will create a new NSView if it has already been deleted). Therefore, you should delete the QMacNativeWidget yourself. In the example, since we create the QMavNativeWidget in “applicationDidFinishLaunching:”, the right place to deallocate it would be “applicationWillTerminate:”. In this regard, the example is incomplete and should be fixed. Best regards, Dr. Gabriel de Dietrich Senior Software Developer qt.digia.com<http://qt.digia.com>
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest