Important: Please read the Qt Code of Conduct -

Search only for bluetooth devices that are turned on

  • Hello to all,
    in my software i want to search only for bluetooth devices that are turned on. Currently, my software also shows me bluetooth devices registered in windows that are not turned on. How can I do?

        if (!localDevice)
            localDevice = new QBluetoothLocalDevice();
        if (!localDevice->isValid())
            emit SignalConnectionNotification(BT_LOCAL_DEVICE_ERROR);
        adapter = localDevice->address();
        discoveryAgent = new QBluetoothDeviceDiscoveryAgent(adapter);
        QObject::connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(BluetoothDeviceDiscovered(QBluetoothDeviceInfo)));
        QObject::connect(discoveryAgent, SIGNAL(finished()), this, SLOT(BluetoothDeviceDiscoveredFinished()));
        QObject::connect(discoveryAgent, SIGNAL(canceled()), this, SLOT(BluetoothDeviceDiscoveredFinished()));

    If instead of finding the devices I find the services everything works. I can only find the services of bluetooth devices that are turned on. But the search takes a long time to finish (more than 2 minutes). This is because I have many bluetooth devices in the windows registry.

    Can anyone help me out?

    I am using Qt 5.14.0 on windows

  • Moderators

    As far as I remember (I haven't used BT on Windows since ~2 years), this is just the way it works. Windows reports all paired devices as "available". It's stupid but that's their way they've done it.

    I think Qt 5.14 or 5.15 added some new functionality (like an experimental BT implementation) which goes around this limitation - please look for it in release announcements or blog posts. It is not compiled into official Qt packages, but can be compiled from source.

  • This post is deleted!

  • @sierdzio
    Thank you for your answer

Log in to reply