Application Start-up Patterns

From Qt Wiki
Revision as of 16:08, 12 December 2016 by EdwardWelbourne (talk | contribs) (Document one architecture for application launch and running, so I can invite others to document the ones I don't know about)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

There are various ways that different platforms support third-party software (e.g. us and our clients) starting a process. The need to fit into each of these constrains the architecture of Qt. We document them here to help illustrate what's needed from our architecture and what the pain points are in the present architecture.

Traditional C main()

This is the simple entry-point where your application is a function – int main(int count, char *args[]) – that gets called by the environment. Your application is started by main() being called and exits when main() returns. Whatever happens in your main() is all your program does.

Since modern applications are generally interactive, this architecture requires that we support an event loop (which other architectures may provide for us). Archetypical (albeit not quite real) code for it looks like:

int main(int count, char *args[])
{
    QApplication app(count, args); // prepare application global state
    // optional set-up
    return app.exec(); // run event loop
}