Qt Bluetooth bonded devices

325 views Asked by At

I would like to connect to already bonded bluetooth device.

Is there a way in Qt Bluetooth that returns List of bonded devices like function getBondedDevices in android studio? Or do I have to scan through all of bluetooth devices and check if the device is already paired like in Bluetooth Scanner Example by Qt where they firstly discover all available devices and then check if they are paired:

void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
{
    const QString label = info.address().toString() + u' ' + info.name();
    const auto items = ui->list->findItems(label, Qt::MatchExactly);
    if (items.isEmpty()) {
        QListWidgetItem *item = new QListWidgetItem(label);
        <strong>QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());</strong>
        item->setForeground(colorForPairing(pairingStatus));
        ui->list->addItem(item);
    }
}

Where QBluetoothDeviceInfo is info of newly discovered device:
discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
connect(discoveryAgent &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &DeviceDiscoveryDialog::addDevice);
0

There are 0 answers