Share my state between different scripts

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

sarlaa
Junior Member
Posts: 19
Joined: Mon Aug 28, 2017 4:39 pm

Share my state between different scripts

Postby sarlaa » Fri Mar 16, 2018 12:46 pm

Hi,

Could you tell me how can I share my state, that contains data related to document with format json, with all scripts as data global ?

I saw this reference https://www.qcad.org/rsforum/viewtopic.php?f=30&t=3187&p=11338&hilit=global+variable#p11338
but it seems that works just for primitifs type variables.

Regards.

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

Re: Share my state between different scripts

Postby andrew » Fri Mar 16, 2018 2:04 pm

The approach for application wide, non-persistent data should work fine also for JSON:

Code: Select all

var appWin = RMainWindowQt.getMainWindow();
appWin.setProperty("MyProperty", {"a":3, "b":7, ...});

var value = appWin.property("MyProperty")["a"];


Return to “QCAD Developers and Contributors”

Who is online

Users browsing this forum: No registered users and 2 guests