Qt6 iOS custom SceneDelegate
-
Hello!
I'm about to add "Quick Actions Menu" feature to my app, followed this guide, the menus shown up on home screen. But when I try to create implementation of
SceneDelegateto catch menu action and add config inInfo.plist, the app in my iPhone just open black window. Did anyone try this and success before?Here is my
Info.plist:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> ... <key>UIApplicationShortcutItems</key> <array> <dict> <key>UIApplicationShortcutItemType</key> <string>com.bnc.MenuItem2</string> <key>UIApplicationShortcutItemTitle</key> <string>Menu Item 2</string> </dict> <dict> <key>UIApplicationShortcutItemType</key> <string>com.bnc.MenuItem1</string> <key>UIApplicationShortcutItemTitle</key> <string>Menu Item 1</string> <key>UIApplicationShortcutItemSubtitle</key> <string>Subtitle 1</string> <key>UIApplicationShortcutItemIconType</key> <string>UIApplicationShortcutIconTypeSearch</string> </dict> </array> <key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).PhoneSceneDelegate</string> </dict> </array> </dict> </dict> ... </dict> </plist>Here is my
obj_c.mm(and add this toqt_add_executable):#import <UIKit/UIKit.h> @interface PhoneSceneDelegate : UIResponder <UIWindowSceneDelegate> @end @implementation PhoneSceneDelegate -(void) windowScene:(UIWindowScene*)windowScene performActionForShortcutItem:(UIApplicationShortcutItem*)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler { NSString *fmt = @"There are other objects in the scene."; NSString *msg = [fmt stringByAppendingString:[shortcutItem type]]; UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Quick Actions Pressed" message:msg preferredStyle:UIAlertControllerStyleAlert]; [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]]; UIWindow* window = [[UIApplication sharedApplication] keyWindow]; UIViewController *ctl = [window rootViewController]; [ctl presentViewController:alertController animated:true completion:nil]; } @end -
I managed to resolve the issue. Actually, Qt6 iOS uses
ApplicationDelegateprotocol, notSceneDelegateprotocol. So just remove stuffs inInfo.plistand the content inobj_c.mmshould be:#import "UIKit/UIKit.h" #import "UserNotifications/UserNotifications.h" @interface QIOSApplicationDelegate @end @interface QIOSApplicationDelegate (MyIOSApplicationDelegate) @end @implementation QIOSApplicationDelegate (MyIOSApplicationDelegate) - (void) application: (UIApplication *) application performActionForShortcutItem: (UIApplicationShortcutItem *) shortcutItem completionHandler: (void (^)(BOOL succeeded)) completionHandler { ... } -
N nguyenbinh has marked this topic as solved on
-
Hey @nguyenbinh may I follow up on this question because I am facing the same issue :D
What version of Qt you are using? Are you aware if Qt6.9.1 still only uses AppDelegate protocol and no Scene-"stuff" at all?I wasn't able to find any documentation or deeper info on this topic at all :s