Application Lifetime

Most applications will have only one Window, or only one main window. These applications can use the Gtk::Application::run(Gtk::Window& window) or Gtk::Application::run(Gtk::Window& window, int argc, char** argv) overloads. They show the window and return when the window has been hidden. This might happen when the user closes the window, or when your code decides to hide() the window. You can prevent the user from closing the window (for instance, if there are unsaved changes) by overriding Gtk::Window::on_delete_event().

Most of our examples use this technique.