Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt6 iOS custom SceneDelegate
Forum Updated to NodeBB v4.3 + New Features

Qt6 iOS custom SceneDelegate

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 571 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nguyenbinh
    wrote on last edited by nguyenbinh
    #1

    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 SceneDelegate to catch menu action and add config in Info.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 to qt_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
    
    1 Reply Last reply
    0
    • N Offline
      N Offline
      nguyenbinh
      wrote on last edited by nguyenbinh
      #2

      I managed to resolve the issue. Actually, Qt6 iOS uses ApplicationDelegate protocol, not SceneDelegate protocol. So just remove stuffs in Info.plist and the content in obj_c.mm should 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 {
      ...
      }
      
      1 Reply Last reply
      1
      • N nguyenbinh has marked this topic as solved on
      • M Offline
        M Offline
        MarcoDC
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved