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

Reusable input widgets

Hand-authored (not codegen-generated) widgets meant to be reused across any form that needs them, not tied to a specific entity's generated Qt facet:

  • OreDateEdit (ores.qt.trading) – a plain QDateEdit with the app's ISO-date/blank-state conventions (isoDate()=/=setIsoDate(), a single-space special value text for "unset"). The default choice for any date field with no calendar sensitivity.
  • HolidayAwareDatePicker (ores.qt.api) – drop-in replacement for OreDateEdit (same isoDate()=/=setIsoDate() contract) that also highlights non-business dates (weekends and holidays, undistinguished – see calendar_date::is_business_day's own doc comment) in its popup calendar grid for one or more calendars, with a hover tooltip naming which calendar(s) a highlighted date applies to. Sourced from the server's materialised calendar_dates table (via fetch_calendar_holidays()), never a live computation. Use this instead of OreDateEdit for any calendar-sensitive date field – trade dates, fixing dates, spot dates, and so on. Call setClientManager() and setCalendarCodes() before the field is shown; the widget lazily (re)loads a practical window (roughly one year back, five years forward) around whichever month the popup happens to be showing, expanding as the user navigates further out, rather than eagerly fetching the full multi-decade materialisation horizon per calendar. See SwapInstrumentForm's fraFixingDateEdit for a worked example.
  • CalendarAssignmentWidget (ores.qt.api) – embeddable list-editor for a text-keyed calendar-assignment junction (e.g. currency_calendars), not a date field itself but the pattern to reach for when an entity needs to manage which calendars apply to it, as opposed to picking a date against calendars already known.

See also

Emacs 29.3 (Org mode 9.6.15)