[SOLVED] Widgets Get/Set value vs text

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

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
CVH
Premier Member
Posts: 3418
Joined: Wed Sep 27, 2017 4:17 pm

[SOLVED] 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
Last edited by CVH on Mon Dec 21, 2020 7:06 am, edited 1 time in total.

User avatar
andrew
Site Admin
Posts: 9037
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: 3418
Joined: Wed Sep 27, 2017 4:17 pm

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. :(

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”