C++ QtBluetooth Win10,如何检查蓝牙适配器是否可用并已打开?
我正在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
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适配器是否可用的正确方法是什么