[Interest] Qt/iOS subclassing and/or delegating

Robert Iakobashvili coroberti at gmail.com
Fri May 29 09:41:25 CEST 2015


On Fri, May 29, 2015 at 8:38 AM, maitai <maitai at virtual-winds.org> wrote:
> Thanks Ben for your reply
>
> After much digging I made some progress but I am still looking for a way to
> temporary lock screen auto rotation.
>
> I have created my own app delegate to catch openUrl(), and surprisingly it
> works. I register my app delegate from main.cpp by calling something like
> this:
>
> void QtAppDelegateInitialize ()
>
> {
>
>     QtAppDelegate *appDelegate = (QtAppDelegate *)[[UIApplication
> sharedApplication] delegate];
>
>     [[UIApplication sharedApplication] setDelegate:[QtAppDelegate
> sharedQtAppDelegate]];
>
>     NSLog(@"Created a new appdelegate");
>
> }
>
>
>
> I then found this very interesting post:
> https://forum.qt.io/topic/48745/how-to-get-didfinishlaunchingwithoptions-called-in-ios-delegate/7
> which links to this bug report: QTBUG-38184.
>
> First question: I am now wondering how my delegate can possibly work since
> it seems I can have only one delegate... so what happened to
> QIOSApplicationDelegate?
>
> I then tried various things to add yet another delegate this time based on
> UINavigationControllerDelegate, but although after much sweat it seems to
> load, the various methods I am trying to override are never called when I
> rotate the device.
>
> Could it be that I should instead modify/interface QIOSApplicationDelegate
> itself and not try to create my own delegates?
>
> A bit confused at this point, I admit ;)
>
> Thanks for any tip
>
> Philippe Lelong
>
>
>
> Le 27-05-2015 20:24, Ben Lau a écrit :
>
>
>
> On 28 May 2015 at 02:07, maitai <maitai at virtual-winds.org> wrote:
>>
>> Hello all,
>>
>> I've started to port on iOS and need to override some methods, like we
>> do easily through Java on Qt/Android. I succeeded to implement an
>> appDelegate in objective-C that works for some events like openURL and
>> such, but for instance I also need to lock automatic screen rotation in
>> some circumstances (but not always).
>
>
> Objective-C has a feature to replace the original method of a class. So you
> may just override the method you needed (In case it don't break Qt)
> Customizing Existing Classes
>
> Example Code:
> quickios/appdelegate.mm at 0b067e17dc13b8533ca3f7dd574d7e81ea17a015 ·
> benlau/quickios
>
> I have tested to override openURL and didFinishLaunchingWithOptions of
> AppDelegate with Qt 5.4.1. This method works.
>
>>
>> I read that I should somehow override "bool
>> UINavigationController::shouldRotate()"
>
>
> Never tried. But should be worth to try? I am also be interested with your
> result.
>
>>
>> Should I reimp (subclass?) UINavigationController and how? Or is there a
>> way to create a new delegate or even better to extend my current
>> appDelegate?
>>
>>
>> I'm new to Objective-C as you can guess... Any clue would be really
>> appreciated :)
>>
>> Thanks
>> Philippe Lelong

Dear Philippe,

Please see the reply Tor Arne inside

https://bugreports.qt.io/browse/QTBUG-42123

That could be an answer - Let it be.

Sincerely,
Robert



More information about the Interest mailing list