Qt UI patterns

Table of Contents

Every ORE Studio Qt entity appears in two places: a shared menu (registered in setup_menus()) and the MDI window toolbar (built in setupToolbar() inside the generated MdiWindow). The two are wired through the controller: the menu action calls showListWindow(); the toolbar actions call slots on the MdiWindow itself. The ground truth for both is in the mustache templates cpp_qt_controller.cpp.mustache and cpp_qt_mdi_window.cpp.mustache. Return to Knowledge.

Plugin registration (on_login / setup_menus)

A Qt plugin registers its entity in two stages:

  1. on_login: create the controller, passing ctx_.main_window, ctx_.mdi_area, ctx_.client_manager, and ctx_.username. Connect its statusMessage and errorMessage signals to the plugin's own statusMessage signal.
  2. setup_menus: receive a shared_menus_context; add a separator and then addAction(icon, label) to the target menu (typically smc.data_management_menu). Connect the action's triggered signal to workspaceController_->showListWindow() (via a guarded lambda that checks the controller is non-null).

Use IconUtils::createRecoloredIcon(Icon::X, IconUtils::DefaultIconColor) for the menu icon. Icon selection is in icon-guidelines.

The plugin file lives at src/{Component}Plugin.cpp. See Qt plugin architecture for the PluginBase contract and lifecycle.

MDI window toolbar

The setupToolbar() method in every generated MdiWindow follows a fixed pattern (encoded in cpp_qt_mdi_window.cpp.mustache):

  1. Create QToolBar, call setMovable(false) and setToolButtonStyle(Qt::ToolButtonTextUnderIcon).
  2. Add Reload — connects to EntityListMdiWindow::reload; also drives the stale indicator via initializeStaleIndicator.
  3. Add a separator.
  4. Add Add — connects to addNew(); tooltip "Add new {entity}".
  5. Add Edit — connects to editSelected(); disabled until a row is selected.
  6. Add Delete — connects to deleteSelected(); disabled until a row is selected.
  7. Add History — connects to showHistory(); disabled until a row is selected.

All icons use IconUtils::createRecoloredIcon(Icon::X, IconUtils::DefaultIconColor). Edit/Delete/History are enabled/disabled from the selection-changed signal of the QTableView.

Templates

The controller and MdiWindow templates are the authoritative source.

Template Covers
cpp_qt_controller.hpp.mustache Controller class declaration
cpp_qt_controller.cpp.mustache on_login wiring + showListWindow
cpp_qt_mdi_window.hpp.mustache MdiWindow class declaration
cpp_qt_mdi_window.cpp.mustache setupToolbar() — the full toolbar pattern

See also

Emacs 29.1 (Org mode 9.6.6)