Created
December 31, 2017 14:08
-
-
Save alediaferia/5fbb50e18ec9ee6310bea0620d8be82a to your computer and use it in GitHub Desktop.
Qt within Objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
NSProcessInfo *procInfo = [NSProcessInfo processInfo]; | |
NSArray *arguments = [procInfo arguments]; | |
int argc = arguments.count; | |
// we need a strong reference for the | |
// argv because it is required to stay | |
// valid as long as the QGuiApplication instance | |
// is valid | |
_argv = (char**)malloc(sizeof(char*) * argc); | |
for (int i = 0; i < argc; ++i) { | |
NSString *arg = [arguments objectAtIndex:i]; | |
_argv[i] = (char *)(malloc([arg lengthOfBytesUsingEncoding:[NSString defaultCStringEncoding]])); | |
strcpy(_argv[i], [arg cStringUsingEncoding:[NSString defaultCStringEncoding]]); | |
} | |
// make sure you keep a strong reference | |
// to the QGuiApplication instance. | |
// you can later free it inside the | |
// - (void)applicationWillTerminate:(UIApplication *)application | |
// delegate method | |
_qApp = new QGuiApplication(argc, _argv); | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment