Changes between Version 1 and Version 2 of TutorialAddingNewParameter


Ignore:
Timestamp:
Nov 20, 2013, 11:56:44 AM (11 years ago)
Author:
Marek Kurdej
Comment:

Added XML modification

Legend:

Unmodified
Added
Removed
Modified
  • TutorialAddingNewParameter

    v1 v2  
    33Let us suppose that we want to add two new parameters to our component.
    44First 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.
     5Second 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.
    66
    771. Add member fields to your component which will contain parameter values.
     
    1111{{{
    1212class MyComponent
     13    : public QObject
     14    , public ComponentBase
    1315{
    1416public:
     
    2729For a ''required'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->required(), "parameter description"```.
    2830
    29 For a ''defaulted'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"```.
     31For a ''optional/defaulted'' parameter: add a line like ```("parameter-name", value<!ParameterType>(&variableToSetWithParameterValue)->default_value(kDefaultParameterValue), "parameter description"```.
    3032
    3133{{{
     
    3537;
    3638}}}
     39
     403. Modify your XML file
     41
     42In 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}}}
     53or
     54{{{
     55<component name="mycomp" type="MyComponent" integer-value="12345" floating-point-value="543.21" />
     56}}}
     57