Page 1 of 1

[SOLVED] Widgets Get/Set value vs text

Posted: Fri Sep 20, 2019 8:22 am
by CVH
What is the difference in essence between:

Code: Select all

widgets["AnyProp"].text = xyz ;
widgets["AnyProp"].setValue(xyz);

Code: Select all

var xyz = widgets["AnyProp"].text;
var xyz = widgets["AnyProp"].getValue();
greatly appreciated,
CVH

Re: Widgets Get/Set value vs text

Posted: Fri Sep 20, 2019 9:05 am
by andrew

Code: Select all

widgets["AnyProp"].text = xyz ;
This is Qt API for QLineEdit and string based, e.g. widgets["AnyProp"].text = "1/6".

Code: Select all

widgets["AnyProp"].setValue(xyz);
This is QCAD API for RMathLineEdit and number based: widgets["AnyProp"].setValue(1/6);

The same is true for retrieving the value. text will give you the string (e.g. "1/6"), while getValue() will give you the value (0.166666666..).

Re: Widgets Get/Set value vs text

Posted: Fri Sep 20, 2019 9:39 am
by CVH
Got it. :wink:
Besides that, Javascript will treat strings that represent real numbers as numbers except with additions.
And RMathLineEdit works with fixed precision 6. :(