Signals and Slots in ECMAScript

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
User avatar
andrew
Site Admin
Posts: 5694
Joined: Fri Mar 30, 2007 6:07 am

Signals and Slots in ECMAScript

Post by andrew » Fri May 25, 2018 10:06 pm

From a QCAD user:
How can I use signals and slots in QCAD scripts, for example to detect if the text in a line edit has changed?

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

Re: Signals and Slots in ECMAScript

Post by andrew » Fri May 25, 2018 10:07 pm

Example:

Code: Select all

var le = new QLineEdit();
...
// call this.validate() on text changes:
le.textChanged.connect(this, "validate");

// call an inline function on text changes:
le.textChanged.connect(this, function(text) { qDebug("text is now: " + text); });
See also:
http://doc.qt.io/archives/qt-4.8/scripting.html

RR88
Junior Member
Posts: 19
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: Signals and Slots in ECMAScript

Post by RR88 » Sat May 26, 2018 4:36 pm

How can I detect the sender? Object.sender() does not exist.
Gentoo/Linux, QCad 3.20 Prof.

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

Re: Signals and Slots in ECMAScript

Post by andrew » Tue Jun 05, 2018 1:48 pm

RR88 wrote:
Sat May 26, 2018 4:36 pm
How can I detect the sender?
I don't think that's available in scripts. Usually a slot is not (and probably shouldn't have to be) interested in the sender.

Post Reply

Return to “QCAD Developers and Contributors”