[Development] A new approach for Qt main()

Thiago Macieira thiago.macieira at intel.com
Mon Dec 12 22:32:01 CET 2016


Em segunda-feira, 12 de dezembro de 2016, às 21:12:31 PST, Morten Sorvig 
escreveu:
> > Can we get a description of what those problems are, for those of us who
> > have  never developed anything for those OSes, so we're not discussing
> > things in the abstract?
> 
> For some background, here’s what typical application startup looks like on
> macOS, NaCl, and Emscripten:
 
> macOS: Define the application delegate, create instance of it in main()
> 
> 
>   // Define application delegate with app lifecycle callbacks
>   @interface AppDelegate ()
>   @end
> 
>   @implementation AppDelegate
>   - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>      // Init application here
>   }
> 
>   - (void)applicationWillTerminate:(NSNotification *)aNotification {
>      // Tear down here
>   }
>   @end
> 
>   // In main, install application delegate and start the app
>   int main(int argc, const char *argv[])
>   {
>        NSApplication *app = [NSApplication sharedApplication];
>        app.delegate = [[AppDelegate alloc] initWithArgc:argc argv:argv];
>        return NSApplicationMain(argc, argv);
>   }

Thanks, but the above makes no sense to me. There are a couple of identifiers 
in your code that I've never seen before and aren't defined in the application 
(NSApplication, NSApplicationMain), plus there's no Qt code anywhere. I don't 
know what the code is doing.

I was hoping you'd give some material on how one currently has to integrate Qt 
with their platform.

> Native Client: Define pp::CreateModule() and return the application module
> (which is a subclass of pp::Module)
> 
>   namespace pp {
>     Module* CreateModule() {
>        return new ApplicationModule();
>     }
>   }

Ok, this is a factory. That's a very important difference. There's also no 
command-line.

Still, I need the example of how one has to integrate with Qt. I have no idea 
what the application module is supposed to do, what it can do, when it can do 
that, etc.

> Emscripten: implement main()
> 
>   int main(int argc, const char *argv[) {
>      // Init application here
>      return 0;
>   }
> 
> main() should/must return to keep the web page responsive. There is API for
> simulating a main that does not return and preserve the stack, see
> emscripten_set_main_loop() in the emscripten documentation.

And obviously there's something else going on, otherwise the code above does 
nothing. In fact, I'm surprised it needs a main function at all...

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list