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:
- Creates the
QApplication, which removes Qt's own options (such as-platformor-style) from the arguments. - Sets the application and organisation names, the organisation domain, the display name and the version. The names (and, on macOS, the domain) select where
QSettingsandQStandardPathskeep the preferences, the profiles and the tile cache, so they must be set before the firstAppSettingsexists; the version isnmeasim::core::kVersion. - Sets the desktop file name and the window icon.
- Applies the look stored under
appearance/themebefore any widget exists, so that the window is built with its palette and View → Theme ticks the stored entry. - Creates and shows the main window, which applies the built-in default profile.
- Loads the profile named by the first argument, or the profile stored under
profile/last_path, throughMainWindow::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. - Starts the simulation when
simulation/autostartis 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