Qt Bluetooth QML APIThe Qt Bluetooth QML API enables an application to scan for devices and connect and interact with them in an easier way than the C++ Classes. However, it is a bit more limited than the C++ API. You can always use the C++ API to create QML plugins with the flexibility you need. Getting StartedTo import the Bluetooth types, use the following: import QtBluetooth 5.0 After importing the Qt Bluetooth QML API you can use its types. This example shows how to connect to a remote RFCOMM (SPP) server using BluetoothSocket: // The socket via which communication to remote host happens BluetoothSocket { id: bluetoothSocket onConnectedChanged: { console.log("bluetoothSocket status: " + connected) if (connected) { titleRow.title = "Connected"; // Send some data to the remote device stringData = "Hello there!"; } else { titleRow.title = "Disconnected"; } } // read incoming data from the remote device onDataAvailable: { print("received data:", stringData); } } QML TypesExamples
|