Signals and Slots in ECMAScript

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
User avatar
andrew
Site Admin
Posts: 9036
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: 9036
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
Full Member
Posts: 51
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.
Arch Linux, QCad 3.22.0 Prof.

User avatar
andrew
Site Admin
Posts: 9036
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 Programming, Script Programming and Contributing”