iOS: add UIView category to get the QWindow it represents

Adding a simple way to get the QWindow pointer from any UIView
makes writing code where you only have UIView pointers a bit easier.

Perhaps we should also investigate if it is worthwhile to make
this category public to the application, to further enhance
working in a mixed environment.

Change-Id: Ic263003dc7683a8d976024cbbbc2558e8472a790
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
bb10
Richard Moe Gustavsen 2012-12-19 10:23:54 +01:00 committed by Tor Arne Vestbø
parent bbb8db9bdb
commit 646b1fd2b6
2 changed files with 15 additions and 0 deletions

View File

@ -49,6 +49,10 @@
class QIOSContext;
class QIOSWindow;
@interface UIView (QIOS)
@property(readonly) QWindow *qwindow;
@end
QT_BEGIN_NAMESPACE
class QIOSWindow : public QPlatformWindow

View File

@ -209,6 +209,17 @@
@end
@implementation UIView (QIOS)
- (QWindow *)qwindow
{
if ([self isKindOfClass:[EAGLView class]])
return static_cast<EAGLView *>(self)->m_qioswindow->window();
return nil;
}
@end
QT_BEGIN_NAMESPACE
QIOSWindow::QIOSWindow(QWindow *window)