Skip to content

main.cpp

file src/app/main.cpp · Applications

Entry point of the desktop application, NMEASimulatorX.

Source src/app/main.cpp

The executable only sets the application's identity, applies the stored look, opens the main window and chooses the profile to start with; everything else lives in the nmeasim_app_lib library, which the tests link and drive without this file, as ADR 0009 decides.

See also

  • docs/adr/0009-desktop-shell.md
  • docs/reference/desktop-app.md, section "Command line".

Summary

File-local functions

Name Description
main() Starts the desktop application and runs its event loop until the main window closes.

File-local functions

main()

int main(int argc, char** argv)

Starts the desktop application and runs its event loop until the main window closes.

Usage: NMEASimulatorX [profile.json]. The startup sequence:

  1. Creates the QApplication, which removes Qt's own options (such as -platform or -style) from the arguments.
  2. Sets the application and organisation names, the organisation domain, the display name and the version. The names (and, on macOS, the domain) select where QSettings and QStandardPaths keep the preferences, the profiles and the tile cache, so they must be set before the first AppSettings exists; the version is nmeasim::core::kVersion.
  3. Sets the desktop file name and the window icon.
  4. Applies the look stored under appearance/theme before any widget exists, so that the window is built with its palette and View → Theme ticks the stored entry.
  5. Creates and shows the main window, which applies the built-in default profile.
  6. Loads the profile named by the first argument, or the profile stored under profile/last_path, through MainWindow::open_initial_profile: a profile given here that cannot be opened (a path that does not exist, for example) is reported, and the last profile is opened instead. Further arguments are ignored.
  7. Starts the simulation when simulation/autostart is set.

There is no other command-line option: an argument such as --help is taken as a profile path and reported because no such file exists.

Parameters

Name Type Description
argc int Number of command-line arguments, including the program name.
argv char** The command-line arguments; QApplication requires both to stay valid for its lifetime, which is the whole of this function.

Returns int: The exit code of QApplication::exec: 0 after a normal quit.

Declared in src/app/main.cpp:51