OGeek|极客世界-中国程序员成长平台

标题: c++ - iOS 上的 Qt 蓝牙 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 17:56
标题: c++ - iOS 上的 Qt 蓝牙

我试图为我的查询寻找答案。这似乎微不足道,但我还找不到答案。

我正在尝试在 iOS 上使用 Qt 蓝牙运行程序。我可以在 MacOS 上成功使用它。

但即使是最基本的代码特性,比如:

QBluetoothLocalDevice localDevice;
QString localDeviceName;

// Check if Bluetooth is available on this device
 if (localDevice.isValid()) {

// Turn Bluetooth on
localDevice.powerOn();

// Read local device name
localDeviceName = localDevice.name();

// Make it visible to others
localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);

// Get connected devices
QList<QBluetoothAddress> remotes;
remotes = localDevice.connectedDevices();
ui->textBrowser->setText(localDevice.name() + "\n" + localDevice.address().toString());

}

给我一​​个空 vector 作为地址。

在 iOS 中运行它是否需要一些特定的设置。我需要在 info.plist 文件上添加某些标志吗?请建议。

有关信息,我正在使用 Qt 5.7 和 xcode 8,在 macOS Sierra macbook 上编程并为 iOS10 构建它。



Best Answer-推荐答案


正如 Paulw11 所指出的,确实,只能在 iOS 设备上使用蓝牙低功耗版本。

虽然 Qt 文档中没有特别提到,但我建议您尝试将 iOS 设备编程为与外围设备通信的 BLE 中央设备。

非常感谢 Paulw11 的意见。

关于c++ - iOS 上的 Qt 蓝牙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40258183/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4