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:
on_login: create the controller, passingctx_.main_window,ctx_.mdi_area,ctx_.client_manager, andctx_.username. Connect itsstatusMessageanderrorMessagesignals to the plugin's ownstatusMessagesignal.setup_menus: receive ashared_menus_context; add a separator and thenaddAction(icon, label)to the target menu (typicallysmc.data_management_menu). Connect the action'striggeredsignal toworkspaceController_->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):
- Create
QToolBar, callsetMovable(false)andsetToolButtonStyle(Qt::ToolButtonTextUnderIcon). - Add Reload — connects to
EntityListMdiWindow::reload; also drives the stale indicator viainitializeStaleIndicator. - Add a separator.
- Add Add — connects to
addNew(); tooltip "Add new {entity}". - Add Edit — connects to
editSelected(); disabled until a row is selected. - Add Delete — connects to
deleteSelected(); disabled until a row is selected. - 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 plainQDateEditwith 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 forOreDateEdit(sameisoDate()=/=setIsoDate()contract) that also highlights non-business dates (weekends and holidays, undistinguished – seecalendar_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 materialisedcalendar_datestable (viafetch_calendar_holidays()), never a live computation. Use this instead ofOreDateEditfor any calendar-sensitive date field – trade dates, fixing dates, spot dates, and so on. CallsetClientManager()andsetCalendarCodes()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. SeeSwapInstrumentForm'sfraFixingDateEditfor 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
- Qt plugin architecture —
PluginBasecontract, plugin lifecycle, menu sections. - icon-guidelines — icon selection for menu and toolbar actions.
- Qt entity patterns — ClientModel, list window, dialog shapes.
- qt-entity-creator — skill that orchestrates Qt UI creation.