simQML Plugin API reference

API functions for creating QML user interfaces. More info about creating user interfaces in QML can be found at https://doc.qt.io/.

simQML.createEngine
simQML.destroyEngine
simQML.imageDataURL
simQML.load
simQML.loadData
simQML.qtVersion
simQML.sendEvent
simQML.sendEventRaw
simQML.setEventHandler
simQML.setEventHandlerRaw

simQML.createEngine

Description Create a QML engine.
Lua synopsis string handle=simQML.createEngine()
Lua parameters -
Lua return values
handle (string): qml engine handle
Python synopsis string handle=simQML.createEngine()

simQML.destroyEngine

Description Destroy the specified QML engine.
Lua synopsis simQML.destroyEngine(string handle)
Lua parameters
handle (string): qml engine handle
Lua return values -
Python synopsis simQML.destroyEngine(string handle)

simQML.imageDataURL

Description Encode image data according to "data" URL scheme (RFC 2397).
Lua synopsis string dataURL=simQML.imageDataURL(buffer data, int width, int height, string format="BMP", int data_format=simqml_image_data_format_rgb888)
Lua parameters
data (buffer): raw image data
width (int): image width
height (int): image height
format (string, default: "BMP"): encoding format (must be "PNG", "JPG" or "BMP")
data_format (int, default: simqml_image_data_format_rgb888): image data format (see simQML.image_data_format)
Lua return values
dataURL (string): data URL
Python synopsis string dataURL=simQML.imageDataURL(buffer data, int width, int height, string format="BMP", int data_format=simqml_image_data_format_rgb888)

simQML.load

Description Load a QML file in the specified engine.
Lua synopsis simQML.load(string engineHandle, string filename)
Lua parameters
engineHandle (string): qml engine handle
filename (string): qml file path
Lua return values -
Python synopsis simQML.load(string engineHandle, string filename)

simQML.loadData

Description Load a QML from a string in the specified engine.
Lua synopsis simQML.loadData(string engineHandle, string data, string basepath="")
Lua parameters
engineHandle (string): qml engine handle
data (string): qml data
basepath (string, default: ""): base path for imports
Lua return values -
Python synopsis simQML.loadData(string engineHandle, string data, string basepath="")
See also

simQML.qtVersion

Description Returns the version of the Qt library.
Lua synopsis int[] version=simQML.qtVersion()
Lua parameters -
Lua return values
version (table of int): version number components as an array
Python synopsis list version=simQML.qtVersion()

simQML.sendEvent

Description send an event with an object payload which will be serialized using JSON
Lua synopsis simQML.sendEvent(string engine, string name, table data)
Lua parameters
engine (string): the handle of the QML engine
name (string): the name of the event
data (table): the object payload
Lua return values -
Python synopsis simQML.sendEvent(string engine, string name, list data)

simQML.sendEventRaw

Description Send an event to QML. In order to receive events in QML, a CoppeliaSimBridge object must be created, and its onEventReceived(name, data) handler must be implemented.

Predefined events sent by the plugin: when the scene is switched, an event with name "onInstanceSwitch" and data consisting of a single boolean JSON-serialized value, which will be true when the QML component's scene becomes active, and false when it becomes inactive.
Lua synopsis simQML.sendEventRaw(string engineHandle, string eventName, string eventData)
Lua parameters
engineHandle (string): qml engine handle
eventName (string): event name
eventData (string): event data
Lua return values -
Python synopsis simQML.sendEventRaw(string engineHandle, string eventName, string eventData)

simQML.setEventHandler

Description registers the event handler for the engine, which will deserialize JSON payloads
Lua synopsis simQML.setEventHandler(string engine, string funcName)
Lua parameters
engine (string): the handle of the QML engine
funcName (string): the name of the function, called with args (engineHandle,eventName,eventData)
Lua return values -
Python synopsis simQML.setEventHandler(string engine, string funcName)

simQML.setEventHandlerRaw

Description Set the event handler to receive events from QML. In order to send events in QML, a CoppeliaSimBridge object must be created, and its sendEvent(name, data) method must be called.

For information about receiving events in QML, see simQML.sendEvent.
Lua synopsis simQML.setEventHandlerRaw(string engineHandle, string functionName)
Lua parameters
engineHandle (string): qml engine handle
functionName (string): function name to be called when event is received: see onEventReceived
Lua return values -
Python synopsis simQML.setEventHandlerRaw(string engineHandle, string functionName)



Constants

Constants used in the various functions. Refer to each constant using enumName.constantName, i.e. simUI.curve_type.xy for xy constant in simUI.curve_type enum.

simQML.image_data_format

gray8
rgb888
bgr888
rgbx8888
rgb32
argb32


Script functions

Script functions are used to call some lua code from the plugin side (tipically used for event handlers).

onEventReceivedRaw

Description Callback for events sent from QML. The event handler must be registered with simQML.setEventHandlerRaw.
Lua synopsis simQML.onEventReceivedRaw(string engineHandle, string eventName, buffer eventData)
Lua parameters
engineHandle (string): qml engine handle
eventName (string): event name
eventData (buffer): event data
Lua return values -
Python synopsis simQML.onEventReceivedRaw(string engineHandle, string eventName, buffer eventData)
See also