问题
I tried to search for an answer for my query. It seems trivial, but I cant find an answer yet.
I am trying to run a program using Qt Bluetooth on iOS. I am able to use it successfully on MacOS.
But even the most basic feature of code like :
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());
}
gives me a null vector as the address.
Is there some specific settings needed to run it in iOS. Do I need to add certain flags on info.plist file? Kindly suggest.
For information, I am using Qt 5.7 and xcode 8, programming on a macOS Sierra macbook and building it for iOS10.
回答1:
As pointed out by Paulw11, indeed, it is only possible to use Bluetooth Low Energy version on iOS devices.
Although not specifically mentioned in the Qt Documentation, I would recommend you to try to program the iOS device as a BLE Central Device that communicates with a peripheral device.
Many thanks to Paulw11 for this input.
来源:https://stackoverflow.com/questions/40258183/qt-bluetooth-on-ios