[Interest] iOS8: Qt 5.3.2 / QML , cannot get UIView from QQuickWindow anymore

Nils Heidorn nils_heidorn at gmx.de
Thu Sep 25 11:28:47 CEST 2014


Hi Richard,
sadly the iOS version does matter.
Maybe i explained it wrong.
The lines i posted work perfectly well on iOS6 & 7.
But in iOS8 the uiview is "nil".
( window() still delivers a valid QQuickWindow, so thats okay )

I AM mixing Qt with native API as is needed for several tasks.
The lines are a near 100% copy of Qt sample code to get hold of the 
native API root viewcontroller.

In a broader perspective, what i have to do using native API is to share 
an image (to Facebook / Twitter / Picasa / Camera Roll ....).
And for that you have to add some ".mm" files and to SHOW the share 
dialog you have to animate it over the root viewcontroller.
And THAT is what i have to retrieve somehow.

But thats probably too much Detail.
The core is:
"QGuiApplication::platformNativeInterface()->nativeResourceForWindow" 
does not seem to work anymore given the same input parameters as in iOS6 
/ 7 :-(

I tried your casting from winId() to uiview but that does not result in 
a valid uiview, accessing it in any way crashes the app.

Please let me know if i am not understanding your explanation and sorry 
for my English, i am not a native english speaker...

Nils


Am 25.09.2014 11:04, schrieb Gustavsen Richard:
> The iOS version should not matter in this case (with respect to how this is implemented in Qt). But since you try to get the view, you are mixing Qt with native APIs. Do you call UIApplicationMain yourself? Perhaps you try to grab the view at a point before the window is fully created? You can check if reinterpret_cast<UIView *>(window()->winId()) returns the view. Otherwise you must be doing something very strange...
>
> -Richard
> ________________________________________
> Fra: interest-bounces+richard.gustavsen=digia.com at qt-project.org [interest-bounces+richard.gustavsen=digia.com at qt-project.org] på vegne av Nils Heidorn [nils_heidorn at gmx.de]
> Sendt: 25. september 2014 09:43
> Til: interest at qt-project.org
> Emne: [Interest] iOS8: Qt 5.3.2 / QML , cannot get UIView from QQuickWindow anymore
>
> Hi !
>
> I got a problem since upgrading my iPad to iOS 8 (had to, customer wants
> me to continue developing on iOS8 NOW).
>
> On iOS 7.x i was used to get the current uiview like this:
>
> UIView *view = static_cast<UIView
> *>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview",
> window()));
>
>
> or if i want to have it “ARC safe”:
>
> UIView *view = (__bridge UIView *)reinterpret_cast<void
> *>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview",
> window()));
>
>
> But on iOS8 this results in “view = nil” :-(
>
> I need the uiview in order to get the UIViewController (as most will):
>
> UIViewController *qtController = [[view window] rootViewController];
>
>
> Sooo, do you know a way to get the uiview (or better the
> UIViewController) on iOS 8 ?
>
> Greetings,
>
> Nils
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list