Widgets Get/Set value vs text

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
CVH
Premier Member
Posts: 850
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Widgets Get/Set value vs text

Post by CVH » Fri Sep 20, 2019 8:22 am

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
QCADpro 3.24.3.10 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

User avatar
andrew
Site Admin
Posts: 7019
Joined: Fri Mar 30, 2007 6:07 am

Re: Widgets Get/Set value vs text

Post by andrew » Fri Sep 20, 2019 9:05 am

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..).

CVH
Premier Member
Posts: 850
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Widgets Get/Set value vs text

Post by CVH » Fri Sep 20, 2019 9:39 am

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. :(
QCADpro 3.24.3.10 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

Post Reply

Return to “QCAD Developers and Contributors”