Qt 用于配对蓝牙设备的密码

Qt 用于配对蓝牙设备的密码,qt,qml,qtquick2,Qt,Qml,Qtquick2,我正在使用Qt5.5开发一个蓝牙应用程序。使用QBluetoothLocalDevice,我可以看到要配对的设备。需要提交密码作为配对过程的一部分。如何做到这一点 将同一设备与我的手机配对,密码条目立即出现 connect(m_localDevice, &QBluetoothLocalDevice::error, this, &BluetoothModel::handleLocalDeviceError); connect(m_localDevice, &QBluetoo

我正在使用Qt5.5开发一个蓝牙应用程序。使用
QBluetoothLocalDevice
,我可以看到要配对的设备。需要提交密码作为配对过程的一部分。如何做到这一点

将同一设备与我的手机配对,密码条目立即出现

connect(m_localDevice, &QBluetoothLocalDevice::error, this, &BluetoothModel::handleLocalDeviceError);
connect(m_localDevice, &QBluetoothLocalDevice::pairingDisplayConfirmation, this, &BluetoothModel::handlePairingDisplayConfirmation);
这不会显示来自
BluetoothModel::handlePairingDisplayConfirmation
插槽的任何调试消息。调试/错误消息如下所示

qt.bluetooth.bluez: Failed to create pairing "org.freedesktop.DBus.Error.NoReply"
BluetoothModel::setPairingStatusMessage "Pairing request failed."

有人试过这样做吗?提前谢谢。

你有没有想过?我也在考虑在应用程序中使用QtBluetooth API,但我在理解如何传递PIN以用于配对请求时遇到了困难,因为它在设备中是硬编码的。@dobey
Qt
bluetooth目前不支持自定义密钥。您必须使用
QDBus
模块实现自定义处理程序。