Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QtBluetooth Win10,如何检查蓝牙适配器是否可用并已打开?_C++_Qt_Windows 10_Bluetooth Lowenergy_Qtbluetooth - Fatal编程技术网

C++ QtBluetooth Win10,如何检查蓝牙适配器是否可用并已打开?

C++ QtBluetooth Win10,如何检查蓝牙适配器是否可用并已打开?,c++,qt,windows-10,bluetooth-lowenergy,qtbluetooth,C++,Qt,Windows 10,Bluetooth Lowenergy,Qtbluetooth,我正在Win10下使用QtBluetooth。很好 但是,由于我的应用程序同时部署在笔记本电脑(可能有也可能没有BT适配器)和台式机(可能没有适配器)上,我想通过编程检查适配器是否可用(存在并启用) 考虑到文档,我测试了4个功能: bool isBluetoothAvailable1() { return !QBluetoothLocalDevice::allDevices().empty(); } bool isBluetoothAvailable2() { QBluetoo

我正在Win10下使用
QtBluetooth
。很好

但是,由于我的应用程序同时部署在笔记本电脑(可能有也可能没有BT适配器)和台式机(可能没有适配器)上,我想通过编程检查适配器是否可用(存在并启用)

考虑到文档,我测试了4个功能:

bool isBluetoothAvailable1()
{
    return !QBluetoothLocalDevice::allDevices().empty();
}

bool isBluetoothAvailable2()
{
    QBluetoothLocalDevice localDevice;
    return localDevice.isValid();
}

bool isBluetoothAvailable3()
{
    std::shared_ptr<QLowEnergyController> created( QLowEnergyController::createPeripheral() );
    if ( created )
    {
        if ( !created->localAddress().isNull() )
            return true;
    }
    return false;
}

bool isBluetoothAvailable4()
{
    std::shared_ptr<QLowEnergyController> created( QLowEnergyController::createCentral( QBluetoothDeviceInfo() ) );
    if ( created )
    {
        if ( !created->localAddress().isNull() )
            return true;
    }
    return false;
}
bool-isBluetoothAvailable1()
{
return!QBluetoothLocalDevice::allDevices().empty();
}
bool-isBluetoothAvailable2()
{
QBluetoothLocalDevice本地设备;
返回localDevice.isValid();
}
bool-isBluetoothAvailable3()
{
std::shared_ptr已创建(QLowEnergyController::createPeripheral());
如果(已创建)
{
如果(!created->localAddress().isNull())
返回true;
}
返回false;
}
bool-isBluetoothAvailable4()
{
std::shared_ptr created(QLowEnergyController::createCentral(QBluetoothDeviceInfo());
如果(已创建)
{
如果(!created->localAddress().isNull())
返回true;
}
返回false;
}
但当我在Win10笔记本电脑上运行代码时,它们都返回false!即使我可以使用
QBluetooth
API搜索并连接远程设备

了解BLE适配器是否可用的正确方法是什么