Changes between Version 1 and Version 2 of TutorialAddingNewParameter
- Timestamp:
- Nov 20, 2013, 11:56:44 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TutorialAddingNewParameter
v1 v2 3 3 Let us suppose that we want to add two new parameters to our component. 4 4 First parameter, named "integer-value" of type ```int``` will be obligatory (required). 5 Second one, named "floating-point-value" of type ```double``` will be defaulted (we will provide a default value and the user will not be obliged to set it.5 Second one, named "floating-point-value" of type ```double``` will be optional/defaulted (we will provide a default value and the user will not be obliged to set it. 6 6 7 7 1. Add member fields to your component which will contain parameter values. … … 11 11 {{{ 12 12 class MyComponent 13 : public QObject 14 , public ComponentBase 13 15 { 14 16 public: … … 27 29 For a ''required'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->required(), "parameter description"```. 28 30 29 For a '' defaulted'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"```.31 For a ''optional/defaulted'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"```. 30 32 31 33 {{{ … … 35 37 ; 36 38 }}} 39 40 3. Modify your XML file 41 42 In the ```<components``` section, modify your component by adding the required and, optionally, the defaulted arguments. 43 44 '''Before the modification:''' 45 {{{ 46 <component name="mycomp" type="MyComponent" /> 47 }}} 48 49 '''After the modification:''' 50 {{{ 51 <component name="mycomp" type="MyComponent" integer-value="12345" /> 52 }}} 53 or 54 {{{ 55 <component name="mycomp" type="MyComponent" integer-value="12345" floating-point-value="543.21" /> 56 }}} 57