Congratulations to our 2022 Qt Champions!

Problem with qt bluetooth(qml type) [Solved]

  • Hello,

    I am working on QtAnroid project, and i have to make a bluetooth connection between a smartphone
    another Bluetooth peripheral (adruino ble shield), i am using qml with QtBluetooth 5.3

    here's a part of my code:

    @ BluetoothService{
    id: blueService
    deviceAddress: "peripheral mac address"
    serviceUuid: "00001100-0000-1000-8000-00805F9B34FB"
    serviceProtocol: BluetoothService.RfcommProtocol

        id: blueSocket
        connected: true
        service: blueService
        onErrorChanged: {
            console.log("Error: " + blueSocket.error) //Errors are printed in Application Output underneeth.
            //blueToothText.text = blueSocket.error;
            blueSocket.connected = false;
        onDataAvailable: {
            console.log("Alone: "+stringData);
            console.log("toString: "+stringData.toString());
            console.log("Length: "+stringData.length);
        onConnectedChanged: {
            console.log("Connection: " + connected);

    and when i run the project i have the following error:

    @qt.bluetooth.qml: Could not start server. Error: 5@

    for information when i add :


    id: btModel
    running: true
    discoveryMode: BluetoothDiscoveryModel.FullServiceDiscovery
    onServiceDiscovered: {
    console.log("Found new service ",

    no service appears in the console, is it normal that i dont show any service of the connected peripheral?if yes is it recommended to use qt bluetooth c++ api instead of qml bluetooth api?

    Any help is appreciated.
    Thank you!

    [Solved] thanks to X-Krys

  • Does your program work in Linux?
    I have a problem with Android and Bluetooth. My application works in Linux but not in Android.
    See my recent post.

  • BLE (Bluetooth Low Energy) is not yet supported in Qt (work in progress in dev branch though).

    An alternative solution is to implement the bluetooth handling in android Java and use "JNI - Java Native Interface": to interface it with your Qt code.
    JNI allows to make call between C++ and Java in both directions.

    Some resources to get started:

    • See doc of QtAndroidExtras module which defines some wrappers for JNI
    • Example of JNI use in Qt sources (look for JNI entry point => JNI_OnLoad function) :
      ** qtbase/src/plugins/platforms/android/androidjnimain.cpp
      ** qtmultimedia\src\plugins\android\src\qandroidmediaserviceplugin.cpp
    • Android BLE guide :

  • Edit:
    [Solved] thanks to X-Krys

Log in to reply