Qt in Parameter Maps and Parameter Blocks
Qt dialogs are the preferred way of managing automatic parameter mapping between parameter blocks and their UIs.
To map a Qt dialog to a parameter block, use the P_AUTO_UI_QT flag in the parameter block descriptor. Individual parameters should not specify UI properties (through the p_ui flag) when using Qt dialogs; instead, the UI is entirely defined as part of the Qt widget - this includes behaviour, naming, localization, and mapping the parameter values.
When specifying the P_AUTO_UI_QT flag on a parameter block descriptor, the usual (Win32) UI specification (dialog resource ID, etc.) are not provided; no UI-definition parameters are to be provided in the paramter block descriptor. When using the P_MULTIMAP flag, the number of parameter maps and their individual IDs are provided as usual, but the IDs are not followed by the usual (Win32) UI specifications. Instead, Qt parameter maps go through ClassDesc2::CreateQtWidget() to retrieve a new Qt widget and associated properties which, in the Win32 world, would have been provided in the parameter block descriptor.
- Mapping Qt controls to parameters in the parameter block
- Whereas Win32 controls are mapped to parameters using the p_ui tag, Qt controls are matched by object name (QObject::setObjectName()) with the parameter's internal (non-localized) name. For each parameter in the parameter block, a search is performed to find all child Qt objects with a matching name:
qtDialog.findChildren<QObjet*>(param_def.int_name)
Every QObject found will be managed by the parameter map if it is deemed compatible (see below). Multiple Qt controls may be mapped to a single parameter by giving them the same object name; for example, a parameter could be mapped to both a slider and a spinner control.
- Compatible Parameter Types and Qt Control Types
- All integer and floating-point parameter types are supported via generic handling through QVariant:
- QComboBox
- The itemData (QComboBox::setItemData()) is the value to set in the parameter block when a selection is made.
- QButtonGroup
- The QButtonGroup groups a set of radio buttons that control an integer parameter value.
- The ID of the button (QButtonGroup::setId()) is the value used in the parameter block.
- All Others
- Any QObject that defines a property "value" is supported.
- Any QObject that does not define a property "value", but has property "text". The value will be reported as read-only through the "text" property.
- TYPE_BOOL:
- Any widget which has a property called "checked".
- If the widget has a property called "checkable", then this property's value must be 'true'.
- TYPE_INODE:
- QPushButton
- Will behave as a node picker. The p_classID and p_sclassID options may be used for filtering nodes. The text on the button is automatically set, by the system, to the node's name, if and only if the P_NO_AUTO_LABELS flag is absent from the paremeter definition.
- All other types are currently unsupported.