User Tools

Site Tools


Modifications to this document are under review.


Signals and Slots

To Do: Update to reflect changes here.

Signals and slots are used for communication between objects. This is a central feature of the Qt toolkit that is also available in DAZ Script (via its QtScript roots). This is an alternative to the 'callback' technique of communication that many other API's, scripting languages, and tool kits use.

Signals

A Signal is emitted when a particular event occurs. You will notice that many of the DAZ Script objects have a 'Signals' section in their documentation. These are not normal functions that can be called, rather these are Signals that are emitted when a particular event occurs on an object of the type in question. You can listen or connect to these signals so that you are notified whenever the event in question occurs.

Slots

Whenever a Signal is emitted, any Slots that are connected to it are executed. A Slot is a function that receives the notification of a Signal. In DAZ Script, any function or method can be a Slot.

Connections

In order for a Signal to activate a Slot, the Slot must be connected to the Signal. In DAZ Script, this is done by calling one of the global DzConnect() functions. Signals may have one or more Slots connected to them. Also, Slots may be listening (connected) to more than one Signal.

Signal-Slot Connections can also be broken or disconnected. This happens automatically when the object that emits the Signal is destroyed. Similarly, if the object with the Slot that receives the Signal is destroyed, the connection is automatically broken. Signal-Slot connections can also be broken programatically by calling one of the global disconnect() functions.