Context QML Type
Configures and initialises the ROS 2 context for a QML application. More...
| Import Statement: | import QtRos2.Core |
| Status: | Experimental Extension |
Properties
- multithreaded : bool
- nodeArgs : list<string>
- threadCount : int
Detailed Description
Context provides a declarative way to initialise the underlying rclcpp context from QML, removing the need for a C++ entry point to call QRos2Context::init().
If no Context item is present, the first Node that is created will auto-initialise the context with default settings (no extra ROS args, and a threaded executor). Use Context when you need explicit control over these options. Or use the QRos2Context type from C++ for even more fine-grained controll.
Note: Only one Context should exist per application. Subsequent instances are silently ignored. The same is true if QRos2Context::init() is called prior to any Context being created.
Note: Property values once and are suggestive. The ROS context might decide to ignore them.
import QtRos2.Core
Context {
// Remap the joint_states topic for a namespaced robot:
nodeArgs: ["--ros-args", "--remap", "/joint_states:=/my_robot/joint_states"]
multithreaded: false
}Place Context before any Node item in the same component so that the context is ready before nodes are created.
Property Documentation
multithreaded : bool
When true, a MultiThreadedExecutor is used instead of the default SingleThreadedExecutor. Defaults to true.
nodeArgs : list<string>
Additional command-line arguments forwarded to rclcpp::init(), e.g. ["--ros-args", "--remap", "/joint_states:=/robot/joint_states"]. Must be set before the component completes and can only be set once.
threadCount : int
Number of threads for the multi-threaded executor. 0 means hardware-concurrency. Ignored when multithreaded is false.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.